/* ═══════════════════════════════════════════════════════════════
   game.css  —  Naruto Arena
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@700;900&family=Rajdhani:wght@400;500;600;700&family=Share+Tech+Mono&display=swap');

:root {
  --ink:     #07030a;
  --paper:   #f0dfc0;
  --orange:  #e85d04;
  --orange2: #f48c06;
  --red:     #c9184a;
  --chakra:  #9b5de5;
  --gold:    #ffd60a;
  --ui-bg:   rgba(6,2,10,0.85);
  --ui-bdr:  rgba(232,93,4,0.18);
  --ui-bdrbr:rgba(232,93,4,0.55);
  --radius:  3px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--ink); }
body {
  font-family: 'Rajdhani', sans-serif; color: var(--paper);
  display: flex; flex-direction: column;
  background-image:
    radial-gradient(ellipse 80% 60% at 15% 10%, rgba(232,93,4,.07) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 85% 90%, rgba(155,93,229,.08) 0%, transparent 60%);
}

/* ── Screens ── */
.screen { display: none; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.screen.active { display: flex; }

/* ══════════════════════════════════════
   LOBBY — JOIN
══════════════════════════════════════ */
#screen-lobby-join {
  align-items: center; justify-content: center; gap: 28px;
  background: radial-gradient(ellipse at 50% 40%, #180a00 0%, #060209 100%);
  overflow-y: auto; padding: 28px 20px;
}

.logo { text-align: center; }
.logo-leaf { font-size: 3rem; display: block; margin-bottom: 4px; filter: drop-shadow(0 0 18px rgba(80,200,80,.5)); }
.logo h1 {
  font-family: 'Cinzel Decorative', serif;
  font-size: clamp(1.8rem, 5vw, 3rem); letter-spacing: 4px;
  background: linear-gradient(135deg, #ff8533 0%, #ffd60a 50%, #ff8533 100%);
  background-size: 200% auto;
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  animation: shimmer 3s linear infinite;
}
@keyframes shimmer { to { background-position: 200% center; } }
.logo .sub { font-size: .78rem; letter-spacing: 6px; color: rgba(240,223,192,.35); text-transform: uppercase; margin-top: 6px; }

.join-box {
  background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.08);
  padding: 28px 32px; width: min(400px, 90vw); display: flex; flex-direction: column; gap: 14px;
}
.join-box h2 { font-family: 'Cinzel Decorative', serif; font-size: .85rem; letter-spacing: 3px; color: var(--orange2); margin-bottom: 4px; }

.field-label { font-size: .72rem; letter-spacing: 2px; text-transform: uppercase; color: rgba(240,223,192,.5); margin-bottom: 4px; }
.field input, .field select {
  width: 100%; padding: 9px 12px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(232,93,4,.3);
  color: var(--paper); font-family: 'Rajdhani', sans-serif; font-size: .95rem; font-weight: 600;
  outline: none; transition: border-color .2s; border-radius: var(--radius);
}
.field input:focus, .field select:focus { border-color: var(--orange); }
.field select option { background: #1a0a00; }

.divider { display: flex; align-items: center; gap: 10px; color: rgba(240,223,192,.25); font-size: .75rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: rgba(255,255,255,.08); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; font-family: 'Rajdhani', sans-serif; font-size: .88rem; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; border: none; cursor: pointer; transition: all .2s; border-radius: var(--radius); }
.btn-primary { background: linear-gradient(135deg, var(--orange), var(--orange2)); color: var(--ink); width: 100%; }
.btn-primary:hover { filter: brightness(1.12); box-shadow: 0 4px 16px rgba(232,93,4,.35); }
.btn-secondary { background: rgba(255,255,255,.07); border: 1px solid rgba(232,93,4,.3); color: var(--paper); width: 100%; }
.btn-secondary:hover { background: rgba(232,93,4,.15); }
.btn:disabled { opacity: .3; cursor: not-allowed; }

.btn-big {
  padding: 14px 48px; font-family: 'Cinzel Decorative', serif; font-size: .9rem; letter-spacing: 4px;
  border: none; cursor: pointer; position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--orange), var(--orange2), #ff8c00);
  color: var(--ink); font-weight: 900; transition: all .25s;
  clip-path: polygon(12px 0%, 100% 0%, calc(100% - 12px) 100%, 0% 100%);
}
.btn-big:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(232,93,4,.4); }

/* ══════════════════════════════════════
   LOBBY — ROOM
══════════════════════════════════════ */
#screen-lobby-room {
  align-items: center; justify-content: center; gap: 20px;
  background: radial-gradient(ellipse at 50% 40%, #180a00 0%, #060209 100%);
  overflow-y: auto; padding: 24px 16px;
}

.room-header { text-align: center; }
.room-code { font-family: 'Cinzel Decorative', serif; font-size: 1.8rem; letter-spacing: 8px; color: var(--gold); }
.room-code-label { font-size: .65rem; letter-spacing: 4px; text-transform: uppercase; color: rgba(240,223,192,.35); margin-top: 4px; }

.room-layout { display: grid; grid-template-columns: 1fr 260px; gap: 20px; width: min(800px, 95vw); }

.panel-box { background: rgba(255,255,255,.03); border: 1px solid var(--ui-bdr); padding: 16px; }
.panel-box h3 { font-family: 'Cinzel Decorative', serif; font-size: .65rem; letter-spacing: 3px; color: var(--orange); margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--ui-bdr); }

.lobby-player { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px solid rgba(255,255,255,.04); font-size: .85rem; }
.lobby-player.dc { opacity: .4; }
.lp-num { width: 20px; text-align: center; font-weight: 700; color: var(--orange2); }
.lp-nick { flex: 1; }
.lp-host { font-size: .6rem; background: rgba(232,93,4,.2); border: 1px solid rgba(232,93,4,.4); padding: 1px 6px; color: var(--orange); letter-spacing: 1px; }
.lp-dc { font-size: .6rem; color: var(--red); }

.map-list { display: flex; flex-direction: column; gap: 4px; max-height: 200px; overflow-y: auto; margin-bottom: 10px; }
.map-item { padding: 7px 10px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.07); font-size: .82rem; cursor: pointer; transition: all .15s; }
.map-item:hover { border-color: rgba(232,93,4,.4); background: rgba(232,93,4,.1); }
.map-item.selected { border-color: var(--orange); background: rgba(232,93,4,.15); color: var(--orange2); }
.mi-meta { font-size: .65rem; color: rgba(240,223,192,.4); margin-left: 6px; }

#lobby-map-name { font-size: .8rem; color: var(--orange2); font-weight: 700; }
#waiting-msg { font-size: .78rem; color: rgba(240,223,192,.4); text-align: center; letter-spacing: 2px; }

/* ══════════════════════════════════════
   GAME SCREEN
══════════════════════════════════════ */
#screen-game { flex: 1; min-height: 0; }

.game-topbar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch;
  background: var(--ui-bg); border-bottom: 1px solid var(--ui-bdr);
  flex-shrink: 0; backdrop-filter: blur(8px);
}

/* Player HUDs container */
#player-huds { display: contents; }

.player-hud {
  display: flex; flex-direction: column; justify-content: center;
  gap: 2px; padding: 6px 12px; position: relative; overflow: hidden;
  border-right: 1px solid var(--ui-bdr);
}
.player-hud:last-child { border-right: none; border-left: 1px solid var(--ui-bdr); text-align: right; align-items: flex-end; }
.player-hud::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, var(--pc, #48cae4), transparent); }
.player-hud:last-child::after { background: linear-gradient(90deg, transparent, var(--pc, #ff6b9d)); }
.player-hud.active { background: rgba(255,255,255,.025); }
.player-hud.dead { opacity: .35; filter: grayscale(.8); }

.hud-name { font-family: 'Cinzel Decorative', serif; font-size: .56rem; letter-spacing: 2px; color: var(--pc, #48cae4); margin-bottom: 1px; }
.hearts { display: flex; gap: 1px; flex-wrap: wrap; max-width: 180px; }
.player-hud:last-child .hearts { justify-content: flex-end; }
.heart { font-size: .7rem; line-height: 1; display: inline-block; transition: all .25s; }
.heart.lost { opacity: .15; filter: grayscale(1); }

.ammo-row { display: flex; gap: 3px; flex-wrap: wrap; align-items: center; }
.player-hud:last-child .ammo-row { justify-content: flex-end; }
.hud-chip { display: inline-flex; align-items: center; gap: 2px; padding: 1px 5px 1px 3px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1); font-size: .6rem; font-weight: 700; color: rgba(240,223,192,.8); border-radius: 2px; line-height: 1.4; }
.hud-chip.zero { opacity: .3; }
.hud-chip .ci { font-size: .72rem; }
.chakra-row { display: flex; align-items: center; gap: 4px; margin-top: 1px; }
.player-hud:last-child .chakra-row { justify-content: flex-end; }
.chakra-label { font-size: .52rem; letter-spacing: 1px; color: rgba(155,93,229,.7); }
.chakra-val { font-size: .55rem; color: rgba(155,93,229,.7); font-weight: 700; }
.chakra-pips { display: flex; gap: 2px; }
.cpip { width: 10px; height: 5px; border-radius: 1px; background: rgba(155,93,229,.15); border: 1px solid rgba(155,93,229,.25); transition: all .3s; }
.cpip.on { background: var(--chakra); border-color: #c77dff; box-shadow: 0 0 4px rgba(155,93,229,.6); }
.poison-badge { font-size: .58rem; color: #c47cff; letter-spacing: 1px; }

.turn-panel {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 5px 18px; border-left: 1px solid var(--ui-bdr); border-right: 1px solid var(--ui-bdr);
  min-width: 150px; gap: 3px;
}
.turn-who { font-family: 'Cinzel Decorative', serif; font-size: .58rem; letter-spacing: 2px; padding: 2px 12px; border: 1px solid var(--ui-bdrbr); transition: color .3s, border-color .3s; }
.turn-round { font-size: .5rem; letter-spacing: 4px; color: rgba(240,223,192,.22); text-transform: uppercase; }
.turn-actions { font-size: .65rem; font-weight: 700; letter-spacing: 1px; background: rgba(255,214,10,.08); border: 1px solid rgba(255,214,10,.2); padding: 2px 10px; color: var(--gold); }
.turn-actions.zero { color: rgba(240,223,192,.28); background: none; border-color: rgba(255,255,255,.05); }

/* ── Game body ── */
.game-body { display: flex; flex: 1; min-height: 0; overflow: hidden; }
.game-canvas-wrap { flex: 1; overflow: auto; background: rgba(4,2,8,.7); display: flex; align-items: flex-start; justify-content: flex-start; position: relative; }
canvas#gameCanvas { display: block; image-rendering: pixelated; cursor: default; flex-shrink: 0; }

/* ── Sidebar ── */
.sidebar {
  width: 196px; background: var(--ui-bg); border-left: 1px solid var(--ui-bdr);
  display: flex; flex-direction: column; padding: 8px; gap: 0;
  overflow-y: auto; flex-shrink: 0; backdrop-filter: blur(8px);
}
.sidebar-section { font-size: .5rem; letter-spacing: 3px; text-transform: uppercase; color: rgba(232,93,4,.6); padding: 6px 4px 4px; border-bottom: 1px solid var(--ui-bdr); margin-bottom: 3px; flex-shrink: 0; }
.abt { display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 5px; padding: 6px 8px; background: transparent; border: 1px solid transparent; color: var(--paper); font-family: 'Rajdhani', sans-serif; font-size: .76rem; font-weight: 600; letter-spacing: .5px; cursor: pointer; transition: all .16s; text-align: left; width: 100%; border-radius: var(--radius); margin-bottom: 2px; }
.abt:hover:not(:disabled) { background: rgba(232,93,4,.1); border-color: rgba(232,93,4,.35); color: var(--orange2); }
.abt.selected { background: rgba(232,93,4,.18); border-color: var(--orange); color: var(--orange2); box-shadow: 0 0 12px rgba(232,93,4,.2); }
.abt:disabled { opacity: .22; cursor: not-allowed; }
.abt .ai { font-size: 1rem; text-align: center; }
.abt .ac { font-size: .56rem; color: var(--chakra); font-weight: 700; background: rgba(155,93,229,.12); border: 1px solid rgba(155,93,229,.25); padding: 1px 5px; border-radius: 2px; white-space: nowrap; }
.abt .ac.free { color: rgba(80,200,80,.9); background: rgba(80,200,80,.08); border-color: rgba(80,200,80,.2); }
.abt-hint { font-size: .58rem; color: rgba(240,223,192,.26); padding: 0 6px 3px 27px; letter-spacing: .5px; }
.sdiv { height: 1px; background: var(--ui-bdr); margin: 5px 0; }
.how-box { padding: 7px; background: rgba(255,255,255,.02); border: 1px solid rgba(255,255,255,.05); border-radius: var(--radius); font-size: .58rem; color: rgba(240,223,192,.35); line-height: 1.7; margin-top: 3px; flex-shrink: 0; }
.how-box b { color: rgba(240,223,192,.58); }
.btn-end { margin-top: auto; flex-shrink: 0; padding: 10px; background: linear-gradient(135deg, var(--orange), var(--orange2)); color: var(--ink); font-family: 'Cinzel Decorative', serif; font-size: .58rem; letter-spacing: 3px; border: none; cursor: pointer; border-radius: var(--radius); transition: all .2s; }
.btn-end:hover { filter: brightness(1.12); box-shadow: 0 4px 16px rgba(232,93,4,.35); }

/* ── Battle log ── */
.log-wrap { flex: 0 0 72px; overflow-y: auto; background: rgba(2,1,4,.65); border-top: 1px solid var(--ui-bdr); padding: 4px 10px; flex-shrink: 0; }
.log-entry { font-family: 'Share Tech Mono', monospace; font-size: .58rem; padding: 1px 0; border-bottom: 1px solid rgba(255,255,255,.02); animation: logIn .22s; }
@keyframes logIn { from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; } }
.log-entry.p0 { color: #48cae4; } .log-entry.p1 { color: #ff6b9d; } .log-entry.p2 { color: #69db7c; }
.log-entry.p3 { color: #ffa94d; } .log-entry.p4 { color: #da77f2; } .log-entry.p5 { color: #74c0fc; }
.log-entry.sys { color: rgba(244,140,6,.85); } .log-entry.dmg { color: var(--red); }
.log-entry.good { color: rgba(80,220,120,.9); } .log-entry.chat { color: rgba(240,223,192,.5); }

/* ── Chat ── */
.chat-row { display: flex; gap: 4px; padding: 4px 6px; border-top: 1px solid var(--ui-bdr); flex-shrink: 0; }
.chat-row input { flex: 1; padding: 5px 8px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1); color: var(--paper); font-family: 'Rajdhani', sans-serif; font-size: .8rem; outline: none; border-radius: var(--radius); }
.chat-row button { padding: 5px 10px; background: rgba(232,93,4,.6); border: none; color: var(--ink); font-family: 'Rajdhani', sans-serif; font-weight: 700; font-size: .75rem; cursor: pointer; border-radius: var(--radius); }

/* ══════════════════════════════════════
   SUMMON MODAL
══════════════════════════════════════ */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.82); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: #0e0618; border: 1px solid rgba(232,93,4,.5); width: min(700px, 95vw); max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 0 60px rgba(155,93,229,.15); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--ui-bdr); font-family: 'Cinzel Decorative', serif; font-size: .8rem; color: var(--orange2); letter-spacing: 2px; }
.modal-close { background: none; border: none; color: rgba(240,223,192,.5); font-size: 1rem; cursor: pointer; transition: color .2s; }
.modal-close:hover { color: var(--red); }
.modal-subhead { padding: 8px 18px; font-size: .72rem; color: rgba(240,223,192,.45); border-bottom: 1px solid var(--ui-bdr); }
.summon-groups { overflow-y: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 16px; }
.summon-group-label { font-size: .6rem; letter-spacing: 3px; text-transform: uppercase; color: var(--orange); margin-bottom: 8px; }
.summon-group { display: flex; flex-direction: column; }
.summon-group > div:first-child { margin-bottom: 6px; }
.summon-group > div:not(:first-child) { display: flex; flex-wrap: wrap; gap: 8px; }
.summon-card { width: 130px; padding: 10px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.1); cursor: pointer; transition: all .18s; }
.summon-card:hover:not(.cant-afford) { border-color: var(--orange); background: rgba(232,93,4,.12); }
.summon-card.cant-afford { opacity: .35; cursor: not-allowed; }
.sc-emoji { font-size: 1.8rem; text-align: center; margin-bottom: 4px; }
.sc-name { font-size: .72rem; font-weight: 700; text-align: center; color: var(--paper); margin-bottom: 4px; }
.sc-stats { display: flex; justify-content: center; gap: 6px; font-size: .62rem; color: rgba(240,223,192,.6); margin-bottom: 4px; }
.sc-cost { font-size: .65rem; font-weight: 700; text-align: center; color: var(--chakra); }
.sc-cost.too-costly { color: var(--red); }
.sc-abilities { margin-top: 5px; border-top: 1px solid rgba(255,255,255,.06); padding-top: 5px; }
.sc-ab { font-size: .57rem; color: rgba(240,223,192,.45); padding: 1px 0; }

/* ══════════════════════════════════════
   GAME OVER
══════════════════════════════════════ */
#screen-gameover { align-items: center; justify-content: center; gap: 22px; background: radial-gradient(ellipse at 50% 40%, #1a0005 0%, #06020a 100%); }
.go-label { font-size: .7rem; letter-spacing: 8px; color: rgba(240,223,192,.3); text-transform: uppercase; }
.winner-name { font-family: 'Cinzel Decorative', serif; font-size: clamp(2rem, 6vw, 3.5rem); letter-spacing: 5px; animation: nameGlow 2s ease-in-out infinite; }
@keyframes nameGlow { 0%,100% { text-shadow: 0 0 20px currentColor; } 50% { text-shadow: 0 0 60px currentColor, 0 0 80px currentColor; } }
.winner-name.p0 { color: #48cae4; } .winner-name.p1 { color: #ff6b9d; } .winner-name.p2 { color: #69db7c; }
.go-sub { font-size: .85rem; letter-spacing: 4px; color: rgba(240,223,192,.38); }
.go-trophy { font-size: 2.5rem; animation: trophyBounce 1.5s ease-in-out infinite; }
@keyframes trophyBounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.go-stats { font-size: .78rem; color: rgba(240,223,192,.42); text-align: center; line-height: 2.2; background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.07); padding: 12px 24px; }

/* ══════════════════════════════════════
   FLOATING EFFECTS
══════════════════════════════════════ */
.floating-dmg { position: absolute; pointer-events: none; font-family: 'Cinzel Decorative', serif; font-size: 1.2rem; font-weight: 900; color: var(--red); text-shadow: 0 0 12px var(--red); animation: fdmg .9s forwards; z-index: 20; }
@keyframes fdmg { 0% { opacity: 1; transform: translateY(0) scale(1); } 100% { opacity: 0; transform: translateY(-50px) scale(1.3); } }
.rep-banner { position: fixed; top: 50%; left: 50%; z-index: 300; pointer-events: none; transform: translate(-50%,-50%); background: rgba(4,2,8,.96); border: 1px solid var(--gold); padding: 18px 32px; text-align: center; animation: repIn .3s cubic-bezier(.34,1.56,.64,1); box-shadow: 0 0 40px rgba(255,214,10,.15); }
@keyframes repIn { from { transform: translate(-50%,-50%) scale(.75); opacity: 0; } to { transform: translate(-50%,-50%) scale(1); opacity: 1; } }
.rep-title { font-family: 'Cinzel Decorative', serif; font-size: 1rem; color: var(--gold); letter-spacing: 3px; }
.rep-sub { font-size: .7rem; color: rgba(240,223,192,.6); margin-top: 4px; letter-spacing: 2px; }
.dc-banner { position: fixed; bottom: 0; left: 0; right: 0; background: rgba(201,24,74,.9); padding: 8px 16px; font-size: .8rem; font-weight: 700; text-align: center; letter-spacing: 1px; z-index: 150; display: none; }

/* ══════════════════════════════════════
   MOBILE  ≤ 700px
══════════════════════════════════════ */
.mob-bar { display: none; }

@media (max-width: 700px) {
  .game-topbar { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; }
  .turn-panel { grid-column: 1/-1; grid-row: 1; flex-direction: row; justify-content: space-between; border-left: none; border-right: none; border-bottom: 1px solid var(--ui-bdr); padding: 4px 10px; min-width: 0; }
  .turn-panel .turn-round { display: none; }
  .sidebar { display: none; }
  .mob-bar { display: flex; flex-direction: column; flex-shrink: 0; background: var(--ui-bg); border-top: 1px solid var(--ui-bdr); backdrop-filter: blur(8px); }
  .mob-row { display: flex; overflow-x: auto; scrollbar-width: none; }
  .mob-row::-webkit-scrollbar { display: none; }
  .mbt { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 6px 8px; min-width: 56px; flex-shrink: 0; background: transparent; border-right: 1px solid var(--ui-bdr); border-top: none; border-left: none; border-bottom: none; color: var(--paper); font-family: 'Rajdhani', sans-serif; font-size: .52rem; font-weight: 700; text-transform: uppercase; cursor: pointer; transition: all .15s; }
  .mbt:disabled { opacity: .22; cursor: not-allowed; }
  .mbt.selected { background: rgba(232,93,4,.18); color: var(--orange2); }
  .mbt .mi { font-size: 1.15rem; line-height: 1; }
  .mbt .mc { font-size: .48rem; color: var(--chakra); font-weight: 700; }
  .mbt .mc.free { color: rgba(80,200,80,.85); }
  .mob-end-btn { padding: 9px; width: 100%; background: linear-gradient(135deg, var(--orange), var(--orange2)); color: var(--ink); font-family: 'Cinzel Decorative', serif; font-size: .58rem; letter-spacing: 3px; border: none; cursor: pointer; }
  .log-wrap { flex: 0 0 50px; }
  .room-layout { grid-template-columns: 1fr; }
}

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,.3); }
::-webkit-scrollbar-thumb { background: rgba(232,93,4,.35); border-radius: 2px; }
