:root {
    --ink: #203d32;
    --muted: #4e7461;
    --green: #b9e4ce;
    --line: #285e4033;
    --yellow: #ffdc72;
    --coral: #ed8976;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { background: var(--green); color: var(--ink); font-family: "Segoe UI", Arial, sans-serif; letter-spacing: 0; }
button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }
[hidden] { display: none !important; }
.arena {
    position: relative; width: 100%; height: 100%; height: 100dvh; overflow: hidden;
    display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto;
    padding: 20px 28px 14px; isolation: isolate;
}
.arena-hud { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); padding-bottom: 14px; }
.score-strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; min-width: 0; width: 220px; }
.score-strip > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.score-strip > div > span, .event-timer > span { font-size: 9px; font-weight: 750; color: var(--muted); }
.score-strip strong { display: block; white-space: nowrap; font-size: 25px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.score-strip small { font-size: .55em; font-weight: 500; color: var(--muted); }
.arena-tools { display: flex; align-items: center; gap: 20px; padding-right: 6px; flex-shrink: 0; }
.event-timer { display: flex; flex-direction: column; gap: 4px; text-align: right; }
.event-timer strong { font: 700 18px/1.1 "Consolas", monospace; font-variant-numeric: tabular-nums; }
.event-timer.ending strong { color: #a33a32; }
.icon-button { position: relative; width: 40px; height: 40px; flex-shrink: 0; border: 1px solid var(--line); border-radius: 6px; background: transparent; display: grid; place-items: center; padding: 0; }
.icon-button img { width: 22px; height: 22px; }
.icon-button:hover { background: #ffffff60; }
.ranking-toggle { background: var(--yellow); border-color: #263d3240; }
.rank-badge { position: absolute; right: -5px; bottom: -5px; min-width: 17px; padding: 1px 3px; background: var(--ink); color: white; border-radius: 3px; font-size: 9px; }
[data-tooltip]::after { content: attr(data-tooltip); position: absolute; top: calc(100% + 9px); right: 0; padding: 6px 9px; background: var(--ink); color: white; border-radius: 4px; font-size: 11px; white-space: nowrap; opacity: 0; pointer-events: none; z-index: 3; }
[data-tooltip]:hover::after, [data-tooltip]:focus-visible::after { opacity: 1; }
.stage { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; padding: 14px 0 0; }
.arena-badge { flex-shrink: 0; font: 700 11px/1.2 "Consolas", monospace; color: var(--muted); padding: 4px 0; }
.duel { width: min(100%, 740px); flex: 1 1 350px; max-height: 390px; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 52px minmax(0, 1fr); gap: 18px; padding: 12px 0; }
.fighter { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; justify-items: center; }
.fighter-label { text-align: center; max-width: 100%; }
.fighter-label > span { display: block; color: var(--muted); font-size: 9px; font-weight: 700; margin-bottom: 4px; }
.fighter-label strong { display: block; max-width: 200px; font-size: 14px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.hand { width: 100%; height: 100%; max-width: 280px; max-height: 280px; min-height: 0; object-fit: contain; align-self: center; }
.player-hand { transform: rotate(18deg); }
.bot-hand { transform: scaleX(-1) rotate(18deg); filter: saturate(.55); }
.versus { align-self: center; text-align: center; font-size: 28px; font-weight: 900; font-style: italic; color: #3c795958; }
.move-name { height: 18px; font-size: 11px; color: var(--muted); font-weight: 600; }
.result { text-align: center; flex-shrink: 0; width: 100%; max-width: 580px; padding: 8px 0 0; }
.result h1 { font-size: 32px; line-height: 1.15; font-weight: 850; margin: 0; overflow-wrap: anywhere; }
.result p { color: var(--muted); font-size: 12px; line-height: 1.4; margin: 7px 0 0; overflow-wrap: anywhere; }
.result[data-outcome=win] h1 { color: #146d43; }
.result[data-outcome=loss] h1 { color: #a33a32; }
.arena-controls { width: min(100%, 460px); justify-self: center; text-align: center; }
.action-slot { min-height: 52px; padding: 8px 0; display: flex; align-items: center; justify-content: center; gap: 8px; }
.join-button, .retry-button { background: var(--ink); color: #fff; border: 0; border-radius: 5px; font-size: 12px; font-weight: 700; padding: 10px 20px; flex-shrink: 0; }
.join-button:hover, .retry-button:hover { background: #315745; }
.join-button:disabled { opacity: .6; cursor: wait; }
.connection-error { color: #94332a; font-size: 11px; line-height: 1.3; margin: 0; overflow-wrap: anywhere; max-width: 220px; max-height: 42px; overflow-y: auto; }
.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.choice { height: 100px; min-width: 0; border: 1px solid #203d324d; border-radius: 6px; box-shadow: 0 4px 0 #38614e66; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px; transition: transform .15s, box-shadow .15s; color: #242e29; }
.choice-rock { background: var(--coral); }
.choice-paper { background: var(--yellow); }
.choice-scissors { background: #eef7f1; }
.choice img { width: 58px; height: 58px; object-fit: contain; }
.choice span { font-size: 13px; font-weight: 800; }
.choice:not(:disabled):hover { transform: translateY(-3px); box-shadow: 0 7px 0 #38614e66; }
.choice:not(:disabled):active, .choice.selected { transform: translateY(3px); box-shadow: 0 1px 0 #38614e66; }
.choice:disabled { opacity: .55; cursor: default; }
.choice.selected { opacity: 1; border: 2px solid var(--ink); }
.session-record { display: block; padding: 15px 0 0; font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ranking-panel { position: fixed; inset: 12px 12px 12px auto; margin: 0; padding: 0; width: min(380px, calc(100% - 24px)); height: calc(100% - 24px); max-height: none; max-width: none; border: 1px solid #517866; border-radius: 8px; background: #f5faf6; color: var(--ink); box-shadow: -12px 0 45px #173c3826; overflow: hidden; }
.ranking-panel[open] { display: flex; flex-direction: column; animation: panel-in .18s ease-out; }
.ranking-panel::backdrop { background: #173c384d; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; padding: 20px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { font-size: 22px; margin: 3px 0 0; }
.eyebrow { display: block; font-size: 9px; font-weight: 750; color: var(--muted); }
.panel-content { padding: 20px; overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
.event-info { display: flex; flex-direction: column; gap: 5px; margin-bottom: 18px; overflow-wrap: anywhere; }
.event-info strong { font-size: 13px; }
.event-info > span { font-size: 10px; color: var(--muted); }
.prize-band { padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 8px; align-items: center; margin-bottom: 20px; }
.prize-number { font-size: 28px; font-weight: 850; overflow-wrap: anywhere; }
.prize-band strong { display: block; font-size: 13px; margin-top: 4px; overflow-wrap: anywhere; }
.prize-band p { grid-column: 1 / -1; font-size: 11px; line-height: 1.5; color: var(--muted); margin: 0; overflow-wrap: anywhere; }
.leaderboard-labels { display: flex; justify-content: space-between; gap: 12px; font-size: 9px; color: var(--muted); padding-bottom: 9px; }
.leaderboard ol { list-style: none; margin: 0; padding: 0; }
.leaderboard li { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding: 12px 4px; font-size: 12px; }
.leaderboard li.mine { background: #dcefe3; }
.position { font-weight: 700; color: var(--muted); }
.position.top { color: #146d43; }
.player-name { overflow-wrap: anywhere; font-weight: 700; }
.player-name small { display: block; font-size: 9px; color: var(--muted); font-weight: 400; margin-top: 4px; line-height: 1.4; }
.player-score { font-size: 18px; font-weight: 800; }
.empty-state { font-size: 12px; padding: 16px 0; color: var(--muted); }
.participant-count { display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; font-size: 11px; }
.end-date { font-size: 10px; margin-top: 8px; color: var(--muted); }
.points-strip { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); margin-top: 20px; padding-top: 16px; font-size: 10px; color: var(--muted); }
.points-strip > span { display: flex; justify-content: space-between; }
.points-strip strong { color: var(--ink); }
.duel.thinking .player-hand { animation: shake-player .3s ease-in-out infinite alternate; }
.duel.thinking .bot-hand { animation: shake-bot .3s ease-in-out infinite alternate; }
@keyframes shake-player { to { transform: rotate(-8deg) translateY(-5px); } }
@keyframes shake-bot { to { transform: scaleX(-1) rotate(-8deg) translateY(-5px); } }
@keyframes panel-in { from { transform: translateX(20px); opacity: 0; } }
@media (max-width: 480px) {
    .arena { padding: 14px 16px 12px; }
    .arena-hud { gap: 10px; padding-bottom: 12px; }
    .score-strip { gap: 20px; }
    .score-strip strong { font-size: 22px; }
    .arena-tools { gap: 13px; }
    .event-timer strong { font-size: 15px; }
    .icon-button { width: 36px; height: 36px; }
    .duel { grid-template-columns: minmax(0, 1fr) 30px minmax(0, 1fr); gap: 6px; max-height: 320px; }
    .fighter-label strong { max-width: 110px; font-size: 12px; }
    .versus { font-size: 22px; }
    .result h1 { font-size: 27px; }
    .choice-grid { gap: 10px; }
    .choice { height: 92px; }
    .choice img { width: 54px; height: 54px; }
}
@media (max-height: 620px) {
    .arena { padding-top: 10px; padding-bottom: 10px; }
    .arena-hud { padding-bottom: 8px; }
    .stage { padding-top: 6px; }
    .duel { padding: 6px 0; max-height: 240px; }
    .result h1 { font-size: 24px; }
    .result p { margin-top: 4px; }
    .action-slot { min-height: 44px; padding: 4px 0; }
    .choice { height: 78px; }
    .choice img { width: 46px; height: 46px; }
    .session-record { padding-top: 10px; }
}
@media (max-height: 420px) {
    .arena { padding: 8px 16px; }
    .arena-hud { padding-bottom: 5px; }
    .score-strip { width: 300px; }
    .score-strip > div { flex-direction: row; align-items: center; gap: 8px; }
    .score-strip strong { min-width: 0; flex: 1; }
    .score-strip > div > span { flex-shrink: 0; }
    .score-strip strong { font-size: 20px; }
    .event-timer { flex-direction: row; align-items: center; gap: 8px; }
    .icon-button { width: 32px; height: 32px; }
    .stage { padding-top: 4px; }
    .arena-badge { font-size: 9px; padding: 0; }
    .fighter-label > span { display: none; }
    .fighter-label strong { font-size: 10px; }
    .duel { padding: 2px 0; gap: 6px; max-height: 180px; width: min(100%, 440px); }
    .move-name { font-size: 9px; height: 12px; }
    .versus { font-size: 18px; }
    .result { padding-top: 2px; }
    .result h1 { font-size: 20px; }
    .result p { font-size: 10px; margin-top: 2px; }
    .action-slot { min-height: 32px; padding: 3px 0; }
    .join-button, .retry-button { padding: 7px 16px; font-size: 11px; }
    .arena-controls { width: min(100%, 380px); }
    .choice { height: 54px; flex-direction: row; gap: 8px; padding: 3px; }
    .choice img { width: 38px; height: 38px; }
    .choice span { font-size: 12px; }
    .session-record { padding-top: 6px; font-size: 9px; }
    .panel-heading { padding: 12px 16px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
