/* ═══════════════════════════════════════════════════════════════════════════
   Poké Sketch — Stylesheet
═══════════════════════════════════════════════════════════════════════════ */

:root {
  --red:      #CC0000;
  --red-dark: #A00000;
  --yellow:   #FFCB05;
  --blue:     #3B4CCA;
  --teal:     #4ECDC4;
  --dark:     #1a1a2e;
  --mid:      #4A5568;
  --light:    #F0F4F8;
  --white:    #FFFFFF;
  --shadow:   0 4px 20px rgba(0,0,0,0.12);
  --shadow-lg:0 8px 32px rgba(0,0,0,0.20);
  --radius:   16px;
  --radius-sm:10px;
}

*, *::before, *::after { box-sizing:border-box; margin:0; padding:0; }
body { font-family:'Nunito',sans-serif; background:var(--light); color:var(--dark); min-height:100vh; }
.hidden { display:none !important; }

/* ─── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  font-family:'Nunito',sans-serif; font-size:1rem; font-weight:800;
  padding:.75rem 1.8rem; border:none; border-radius:50px; cursor:pointer;
  transition:transform .12s, box-shadow .12s, filter .12s;
  display:inline-block; text-align:center; text-decoration:none;
}
.btn:hover  { transform:translateY(-2px); box-shadow:0 6px 20px rgba(0,0,0,.18); filter:brightness(1.05); }
.btn:active { transform:translateY(0); }
.btn-create { background:var(--red);  color:white; }
.btn-join   { background:var(--blue); color:white; }

/* ─── HOME PAGE ─────────────────────────────────────────────────────────────── */
.home-body {
  display:flex; align-items:center; justify-content:center; min-height:100vh;
  padding:2rem;
  /* Background image — falls back to gradient if file isn't present */
  background:
    linear-gradient(rgba(26,26,46,0.72), rgba(26,26,46,0.72)),
    url('background.png') center/cover no-repeat fixed;
}

.home-wrapper {
  width:100%; max-width:840px;
  display:flex; flex-direction:column; align-items:center; gap:2rem;
}

.home-logo { text-align:center; }
.logo-icon-wrap {
  display: inline-block;
  width: 96px; height: 96px;
  border-radius: 50%;
  box-shadow: 0 0 24px 8px rgba(204, 0, 0, 0.45);
  animation: spark 1.8s ease-in-out infinite;
  margin: 0 auto 0;
}
.logo-icon-wrap img {
  display: block;
  width: 96px;
  height: 96px;
}
.lobby-logo-img { width:20px; height:20px; vertical-align:middle; margin-right:.4rem; }
@keyframes spark {
  0%,100%{ transform:scale(1) rotate(-3deg); }
  50%    { transform:scale(1.15) rotate(3deg); }
}
.home-logo h1 {
  font-family:'Press Start 2P',cursive; font-size:2rem; color:var(--yellow);
  margin-top:.5rem;
  text-shadow:3px 3px 0 var(--red), 5px 5px 0 rgba(0,0,0,.3);
  line-height:1.3;
}
.home-logo p { font-size:1rem; color:rgba(255,255,255,.8); font-weight:700; margin-top:.6rem; }

.home-cards {
  display:flex; gap:1.5rem; align-items:stretch; width:100%;
  flex-wrap:wrap; justify-content:center;
}
.home-card {
  background:rgba(255,255,255,0.96); border-radius:var(--radius);
  padding:2rem 1.8rem; box-shadow:var(--shadow-lg);
  display:flex; flex-direction:column; gap:1rem;
  flex:1; min-width:260px; max-width:340px;
  border-top:5px solid transparent;
  transition:transform .2s;
}
.home-card:hover { transform:translateY(-4px); }
.card-create { border-top-color:var(--red); }
.card-join   { border-top-color:var(--blue); }
.home-card h2 { font-family:'Press Start 2P',cursive; font-size:.85rem; color:var(--dark); line-height:1.5; }
.home-card p  { font-size:.9rem; color:var(--mid); font-weight:600; }
.home-divider { font-weight:800; font-size:1rem; color:rgba(255,255,255,.7); align-self:center; }

.input-group input {
  width:100%; padding:.7rem 1rem;
  border:2.5px solid #E2E8F0; border-radius:var(--radius-sm);
  font-family:'Nunito',sans-serif; font-size:.95rem; font-weight:700;
  transition:border-color .2s; outline:none; color:var(--dark); background:#fafafa;
}
.input-group input:focus { border-color:var(--red); background:white; }
.card-join .input-group input:focus { border-color:var(--blue); }

.home-error {
  background:#FEE2E2; color:#C53030; border-radius:var(--radius-sm);
  padding:.7rem 1.2rem; font-weight:700; font-size:.88rem;
  text-align:center; width:100%; max-width:600px;
}

/* ─── AVATAR MODAL ──────────────────────────────────────────────────────────── */
.avatar-modal-backdrop {
  position:fixed; inset:0; background:rgba(26,26,46,.78);
  display:flex; align-items:center; justify-content:center;
  z-index:100; backdrop-filter:blur(4px);
}
.avatar-modal {
  background:white; border-radius:var(--radius); padding:2rem;
  width:90%; max-width:360px;
  display:flex; flex-direction:column; align-items:center; gap:1rem;
  box-shadow:var(--shadow-lg); border-top:5px solid var(--red);
  animation:pop-in .3s cubic-bezier(.34,1.56,.64,1);
}
.avatar-modal h2 { font-family:'Press Start 2P',cursive; font-size:.85rem; color:var(--dark); line-height:1.6; }
.avatar-modal p  { font-size:.88rem; color:var(--mid); font-weight:600; }
.avatar-canvas-wrap { border:3px solid var(--dark); border-radius:var(--radius-sm); overflow:hidden; cursor:crosshair; }
#avatar-canvas { display:block; width:200px; height:200px; }

.avatar-palette { display:flex; gap:5px; flex-wrap:wrap; justify-content:center; max-width:240px; }
.avatar-swatch {
  width:22px; height:22px; border-radius:50%; border:3px solid transparent;
  cursor:pointer; transition:transform .1s; box-shadow:0 1px 3px rgba(0,0,0,.2);
}
.avatar-swatch:hover  { transform:scale(1.25); }
.avatar-swatch.active { border-color:var(--dark); transform:scale(1.15); }

.avatar-tools { display:flex; align-items:center; gap:.5rem; flex-wrap:wrap; justify-content:center; }
.avatar-size { background:none; border:2px solid transparent; border-radius:50%; cursor:pointer; color:var(--dark); line-height:1; padding:3px; transition:border-color .1s; }
.avatar-size:nth-child(1){font-size:.55rem;}
.avatar-size:nth-child(2){font-size:.9rem;}
.avatar-size:nth-child(3){font-size:1.4rem;}
.avatar-size.active,.avatar-size:hover { border-color:var(--dark); }
.avatar-sep { width:1px; height:20px; background:#E2E8F0; }
.avatar-tool-btn {
  font-family:'Nunito',sans-serif; font-size:.8rem; font-weight:700;
  padding:.35rem .75rem; border:2px solid #E2E8F0; background:white;
  border-radius:var(--radius-sm); cursor:pointer; transition:background .15s;
}
.avatar-tool-btn:hover  { background:var(--light); }
.avatar-tool-btn.active { background:#FFF0F0; border-color:var(--red); }
.avatar-tool-btn.danger:hover { background:#FEE2E2; border-color:var(--red); }
.avatar-actions { display:flex; gap:.75rem; width:100%; }
.avatar-actions .btn { flex:1; }

/* ─── GAME BODY ─────────────────────────────────────────────────────────────── */
.game-body { background:#e8ecf0; min-height:100vh; }
.screen { width:100%; }

/* ─── LOBBY ─────────────────────────────────────────────────────────────────── */
#screen-lobby {
  display:flex; align-items:center; justify-content:center;
  min-height:100vh; padding:2rem;
  background:
    linear-gradient(rgba(26,26,46,0.72), rgba(26,26,46,0.72)),
    url('background.png') center/cover no-repeat fixed;
}
.lobby-panel {
  background:white; border-radius:var(--radius); padding:2.5rem;
  box-shadow:var(--shadow-lg); width:100%; max-width:480px;
  display:flex; flex-direction:column; align-items:center; gap:1.2rem;
  text-align:center; border-top:6px solid var(--red);
}
.lobby-logo { font-family:'Press Start 2P',cursive; font-size:1rem; color:var(--red); text-shadow:2px 2px 0 var(--yellow); }

.room-code-box {
  display:flex; align-items:center; gap:.7rem;
  background:var(--light); border-radius:var(--radius-sm);
  padding:.7rem 1.3rem; border:2px solid #E2E8F0;
}
.room-code-box .label { font-weight:800; font-size:.8rem; color:var(--mid); }
.room-code { font-family:'Press Start 2P',cursive; font-size:1.4rem; color:var(--red); letter-spacing:.12em; }
.btn-copy { background:none; border:none; cursor:pointer; font-size:1.1rem; padding:.2rem .4rem; border-radius:6px; transition:background .15s; }
.btn-copy:hover { background:#e2e8f0; }
.lobby-hint { font-size:.85rem; color:var(--mid); font-weight:600; }
.lobby-players-title { font-weight:800; font-size:.85rem; color:var(--mid); text-transform:uppercase; letter-spacing:.05em; align-self:flex-start; }

.lobby-player-list { list-style:none; width:100%; display:flex; flex-direction:column; gap:.45rem; }
.lobby-player-list li {
  background:var(--light); border-radius:var(--radius-sm);
  padding:.55rem 1rem; font-weight:700; font-size:.95rem;
  display:flex; align-items:center; gap:.6rem;
}
.host-badge {
  font-size:.7rem; background:var(--yellow); color:var(--dark);
  border-radius:50px; padding:.15rem .5rem; font-weight:800; margin-left:auto;
}
.disconnected-tag { font-size:.7rem; color:#f59e0b; font-weight:700; }

/* Player avatars */
.player-avatar { border-radius:50%; object-fit:cover; border:2px solid #E2E8F0; flex-shrink:0; }
.player-icon   { font-size:1rem; flex-shrink:0; }
.player-name-text { flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* ─── Host Settings Panel ───────────────────────────────────────────────────── */
.host-settings {
  width:100%; background:var(--light); border-radius:var(--radius-sm);
  padding:1rem 1.2rem; border:2px solid #E2E8F0;
  display:flex; flex-direction:column; gap:.75rem;
}
.settings-title { font-family:'Press Start 2P',cursive; font-size:.65rem; color:var(--mid); text-align:left; line-height:1.6; }
.settings-grid { display:grid; grid-template-columns:1fr 1fr; gap:.75rem; }
.settings-grid label { display:flex; flex-direction:column; gap:.35rem; text-align:left; }
.settings-grid label span { font-size:.78rem; font-weight:800; color:var(--mid); text-transform:uppercase; letter-spacing:.04em; }
.settings-grid select {
  padding:.45rem .65rem; border:2px solid #E2E8F0; border-radius:var(--radius-sm);
  font-family:'Nunito',sans-serif; font-size:.9rem; font-weight:700;
  color:var(--dark); background:white; cursor:pointer; outline:none;
  transition:border-color .2s;
}
.settings-grid select:focus { border-color:var(--red); }

.settings-gens-label { font-size:.78rem; font-weight:800; color:var(--mid); text-transform:uppercase; letter-spacing:.04em; text-align:left; }
.settings-gens { display:flex; gap:.6rem; flex-wrap:wrap; }
.gen-checkbox {
  display:flex; align-items:center; gap:.5rem;
  background:white; border:2px solid #E2E8F0; border-radius:var(--radius-sm);
  padding:.45rem .75rem; cursor:pointer; transition:border-color .15s, background .15s;
  font-size:.88rem; font-weight:700; user-select:none; flex:1; min-width:120px;
}
.gen-checkbox:hover { border-color:var(--red); background:#fff5f5; }
.gen-checkbox input[type="checkbox"] { accent-color:var(--red); width:15px; height:15px; cursor:pointer; flex-shrink:0; }
.gen-checkbox input[type="checkbox"]:checked + span { color:var(--red); }
.gen-checkbox span { line-height:1.3; }
.gen-checkbox em { display:block; font-style:normal; font-size:.72rem; color:var(--mid); font-weight:600; }
.gen-error { background:#FEE2E2; color:#C53030; border-radius:var(--radius-sm); padding:.4rem .75rem; font-size:.8rem; font-weight:700; }

.lobby-waiting-msg { font-size:.88rem; color:var(--mid); font-weight:600; }

/* ─── GAME SCREEN ────────────────────────────────────────────────────────────── */
#screen-game { display:flex; flex-direction:column; height:100vh; overflow:hidden; }

.game-topbar {
  background:var(--dark); color:white;
  display:flex; align-items:center; justify-content:space-between;
  padding:0 1.5rem; height:56px; flex-shrink:0;
  border-bottom:3px solid var(--red);
}
.round-label { font-family:'Press Start 2P',cursive; font-size:.6rem; color:#94a3b8; line-height:1.6; }
.word-display { font-family:'Press Start 2P',cursive; font-size:1rem; letter-spacing:.25em; color:var(--yellow); text-align:center; min-width:200px; line-height:1.6; }
.timer-ring {
  width:44px; height:44px; border-radius:50%; background:var(--red);
  display:flex; align-items:center; justify-content:center;
  font-family:'Press Start 2P',cursive; font-size:.75rem; color:white; transition:background .4s;
}
.timer-ring.warning { background:#D97706; }
.timer-ring.danger  { background:#B91C1C; animation:pulse .5s ease-in-out infinite; }
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.12)} }

.game-main { display:flex; flex:1; overflow:hidden; }
.game-sidebar { width:190px; flex-shrink:0; display:flex; flex-direction:column; background:white; }
.sidebar-title { font-weight:800; font-size:.75rem; text-transform:uppercase; letter-spacing:.06em; padding:.8rem 1rem .5rem; color:var(--mid); border-bottom:2px solid var(--light); }

.player-list { list-style:none; overflow-y:auto; flex:1; padding:.5rem; display:flex; flex-direction:column; gap:.4rem; }
.player-list li { display:flex; align-items:center; gap:.45rem; padding:.5rem .7rem; border-radius:var(--radius-sm); font-weight:700; font-size:.85rem; transition:background .2s; }
.player-list li.drawing      { background:#FFF3CD; border-left:3px solid var(--yellow); }
.player-list li.disconnected { opacity:.5; text-decoration:line-through; }
.player-score { margin-left:auto; font-family:'Press Start 2P',cursive; font-size:.6rem; color:var(--red); }

.game-center { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; padding:.5rem; background:#dde3ea; overflow:hidden; gap:.5rem; }
.canvas-wrapper { position:relative; flex:1; width:100%; display:flex; align-items:center; justify-content:center; }
#draw-canvas   { background:white; border-radius:var(--radius-sm); box-shadow:var(--shadow); max-width:100%; max-height:100%; display:block; border:3px solid var(--dark); touch-action:none; }
#cursor-canvas {
  position: absolute; pointer-events: none;
  max-width: 100%; max-height: 100%;
  border-radius: var(--radius-sm); touch-action:none;
}

/* ─── Overlays ──────────────────────────────────────────────────────────────── */
.overlay {
  position:absolute; inset:0; background:rgba(26,26,46,.75);
  display:flex; align-items:center; justify-content:center;
  border-radius:var(--radius-sm); z-index:10; backdrop-filter:blur(3px);
}
.overlay-box {
  background:white; border-radius:var(--radius); padding:2rem;
  max-width:400px; width:90%; text-align:center;
  box-shadow:var(--shadow-lg); display:flex; flex-direction:column; gap:1rem;
  animation:pop-in .3s cubic-bezier(.34,1.56,.64,1); border-top:5px solid var(--red);
}
@keyframes pop-in { from{transform:scale(.8);opacity:0} to{transform:scale(1);opacity:1} }
.overlay-box h3 { font-family:'Press Start 2P',cursive; font-size:.9rem; color:var(--dark); line-height:1.6; }
.overlay-box p  { color:var(--mid); font-weight:700; font-size:.9rem; }
.overlay-box strong { color:var(--red); }

.word-choices { display:flex; flex-direction:column; gap:.7rem; margin-top:.5rem; }
.word-choice-btn {
  font-family:'Press Start 2P',cursive; font-size:.75rem; padding:.9rem 1.5rem;
  border:3px solid var(--red); background:white; border-radius:var(--radius-sm);
  cursor:pointer; transition:background .15s,color .15s,transform .1s; color:var(--dark); line-height:1.6;
}
.word-choice-btn:hover { background:var(--red); color:white; transform:scale(1.03); }

.round-scores,.final-scores { display:flex; flex-direction:column; gap:.5rem; width:100%; }
.score-row { display:flex; justify-content:space-between; align-items:center; padding:.5rem .9rem; background:var(--light); border-radius:var(--radius-sm); font-weight:700; font-size:.9rem; }
.score-row .pts { font-family:'Press Start 2P',cursive; font-size:.6rem; color:var(--red); }
.score-row.top { background:#FFF3CD; border:2px solid var(--yellow); }
.next-round-msg { font-size:.8rem; color:var(--mid); }

.gameover-actions { display:flex; gap:.75rem; justify-content:center; flex-wrap:wrap; margin-top:.25rem; }

/* ─── Drawing toolbar ────────────────────────────────────────────────────────── */
.draw-toolbar {
  display:flex; align-items:center; gap:.8rem; background:white;
  border-radius:50px; padding:.5rem 1.2rem; box-shadow:var(--shadow);
  border:2px solid #e2e8f0; flex-wrap:wrap; justify-content:center;
}
.toolbar-section { display:flex; align-items:center; gap:.4rem; }
.toolbar-section+.toolbar-section { border-left:2px solid var(--light); padding-left:.8rem; }
.color-palette { display:flex; gap:5px; flex-wrap:wrap; max-width:220px; }
.color-swatch { width:24px; height:24px; border-radius:50%; border:3px solid transparent; cursor:pointer; transition:transform .1s; box-shadow:0 1px 3px rgba(0,0,0,.2); }
.color-swatch:hover  { transform:scale(1.25); }
.color-swatch.active { border-color:var(--dark); transform:scale(1.2); }
.size-btn { background:none; border:2px solid transparent; border-radius:50%; cursor:pointer; color:var(--dark); line-height:1; padding:3px; }
.size-btn:nth-child(1){font-size:.55rem;}
.size-btn:nth-child(2){font-size:.95rem;}
.size-btn:nth-child(3){font-size:1.45rem;}
.size-btn.active,.size-btn:hover { border-color:var(--dark); }
.tool-btn { font-size:1.15rem; background:none; border:2px solid transparent; border-radius:var(--radius-sm); cursor:pointer; padding:4px 7px; transition:background .15s,border-color .15s; }
.tool-btn:hover,.tool-btn.active { background:var(--light); border-color:#CBD5E0; }
.tool-btn.danger:hover { background:#FEE2E2; border-color:var(--red); }

/* ─── Chat ───────────────────────────────────────────────────────────────────── */
.chat-log { flex:1; overflow-y:auto; padding:.6rem; display:flex; flex-direction:column; gap:.35rem; font-size:.83rem; }
.chat-msg { background:var(--light); border-radius:var(--radius-sm); padding:.4rem .65rem; word-break:break-word; line-height:1.4; display:flex; align-items:flex-start; gap:.4rem; flex-wrap:wrap; }
.msg-name  { font-weight:800; color:var(--red); }
.chat-msg.correct { background:#D1FAE5; color:#065F46; font-weight:700; text-align:center; font-size:.88rem; justify-content:center; }
.chat-msg.system  { color:var(--mid); text-align:center; font-style:italic; background:none; font-size:.8rem; justify-content:center; }
.chat-msg.hint    { background:#EDE9FE; color:#4C1D95; font-weight:700; font-size:.82rem; border-left:3px solid #7C3AED; }
.chat-avatar      { width:20px; height:20px; border-radius:50%; object-fit:cover; flex-shrink:0; }

.chat-input-row { display:flex; gap:.4rem; padding:.6rem; border-top:2px solid var(--light); }
.guess-wrap { flex:1; position:relative; }
.guess-wrap input { width:100%; padding:.5rem .75rem; border:2px solid var(--light); border-radius:50px; font-family:'Nunito',sans-serif; font-weight:700; font-size:.83rem; outline:none; transition:border-color .2s; }
.guess-wrap input:focus { border-color:var(--red); }

/* Autocomplete */
.autocomplete-list {
  position:absolute; bottom:calc(100% + 4px); left:0; right:0;
  background:white; border:2px solid var(--red); border-radius:var(--radius-sm);
  list-style:none; overflow:hidden; box-shadow:0 -4px 16px rgba(0,0,0,.12); z-index:50;
}
.autocomplete-list li { padding:.45rem .85rem; font-size:.85rem; font-weight:700; cursor:pointer; transition:background .1s; }
.autocomplete-list li:hover,.autocomplete-list li.ac-active { background:#FFF0F0; color:var(--red); }
.autocomplete-list li strong { color:var(--red); font-weight:900; }

.chat-input-row button {
  background:var(--red); color:white; border:none; border-radius:50%;
  width:36px; height:36px; cursor:pointer; font-size:.95rem; flex-shrink:0;
  transition:filter .15s,transform .1s;
}
.chat-input-row button:hover  { filter:brightness(1.1); transform:scale(1.05); }
.chat-input-row button:active { transform:scale(.95); }

/* ─── Game-over gallery ───────────────────────────────────────────────────────── */
.gameover-box { max-width:680px !important; max-height:88vh; overflow-y:auto; }
.gallery-title { font-family:'Press Start 2P',cursive; font-size:.7rem; color:var(--mid); text-transform:uppercase; letter-spacing:.06em; align-self:flex-start; margin-top:.5rem; }
.drawing-gallery { display:grid; grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); gap:.9rem; width:100%; }
.gallery-card { background:var(--light); border-radius:var(--radius-sm); overflow:hidden; display:flex; flex-direction:column; border:2px solid #E2E8F0; transition:transform .15s,box-shadow .15s; }
.gallery-card:hover { transform:translateY(-3px); box-shadow:var(--shadow); }
.gallery-img { width:100%; aspect-ratio:800/540; object-fit:cover; display:block; border-bottom:2px solid #E2E8F0; background:white; }
.gallery-label { padding:.4rem .6rem .2rem; display:flex; flex-direction:column; gap:.15rem; }
.gallery-pokemon { font-family:'Press Start 2P',cursive; font-size:.6rem; color:var(--red); line-height:1.5; }
.gallery-drawer  { font-size:.75rem; font-weight:700; color:var(--mid); }
.gallery-dl { margin:.4rem .6rem .6rem; font-size:.75rem !important; padding:.4rem .8rem !important; text-decoration:none; text-align:center; border-radius:50px; }

/* ─── Bug report button ──────────────────────────────────────────────────────── */
.bug-btn {
  position: fixed; bottom: 1.25rem; left: 1.25rem; z-index: 200;
  background: var(--dark); color: white; border: 2px solid rgba(255,255,255,.15);
  border-radius: 50px; padding: .45rem .9rem;
  font-family: 'Nunito', sans-serif; font-size: .8rem; font-weight: 800;
  cursor: pointer; opacity: .6; transition: opacity .2s, transform .15s, box-shadow .2s;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.bug-btn:hover { opacity: 1; transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.3); }

/* Bug report modal */
.bug-modal-backdrop {
  position: fixed; inset: 0; background: rgba(26,26,46,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 300; backdrop-filter: blur(4px);
}
.bug-modal {
  background: white; border-radius: var(--radius); padding: 2rem;
  width: 90%; max-width: 420px;
  display: flex; flex-direction: column; gap: 1rem;
  box-shadow: var(--shadow-lg); border-top: 5px solid var(--red);
  animation: pop-in .25s cubic-bezier(.34,1.56,.64,1);
}
.bug-modal h2 { font-family: 'Press Start 2P', cursive; font-size: .85rem; color: var(--dark); line-height: 1.6; }
.bug-modal p  { font-size: .88rem; color: var(--mid); font-weight: 600; }
.bug-modal textarea {
  width: 100%; padding: .75rem; border: 2px solid #E2E8F0; border-radius: var(--radius-sm);
  font-family: 'Nunito', sans-serif; font-size: .9rem; font-weight: 600; color: var(--dark);
  resize: vertical; outline: none; transition: border-color .2s;
}
.bug-modal textarea:focus { border-color: var(--red); }
.bug-error  { background: #FEE2E2; color: #C53030; border-radius: var(--radius-sm); padding: .5rem .85rem; font-size: .82rem; font-weight: 700; }
.bug-actions { display: flex; gap: .75rem; }
.bug-actions .btn { flex: 1; }

/* ─── Toast notification ──────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 5rem; left: 50%; transform: translateX(-50%) translateY(12px);
  background: var(--dark); color: white; padding: .6rem 1.4rem;
  border-radius: 50px; font-size: .88rem; font-weight: 700;
  opacity: 0; transition: opacity .3s, transform .3s; pointer-events: none; z-index: 999;
}
.toast.toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── Star rating ─────────────────────────────────────────────────────────────── */
.star-row { display: flex; gap: .25rem; font-size: 1.8rem; margin-bottom: .25rem; }
.star { cursor: pointer; color: #CBD5E0; transition: color .1s; user-select: none; }
.star.active { color: var(--yellow); }

/* ─── Feedback gameover button ────────────────────────────────────────────────── */
.gameover-actions { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; margin-top: .5rem; }

/* ─── Vote buttons & winner ──────────────────────────────────────────────────── */
.gallery-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: .3rem .6rem .5rem; gap: .4rem;
}
.gallery-dl { flex: 1; font-size: .72rem !important; padding: .35rem .6rem !important; text-decoration: none; text-align: center; border-radius: 50px; }
.vote-btn {
  background: none; border: 2px solid #FDA4AF; border-radius: 50px;
  padding: .3rem .65rem; cursor: pointer; font-size: .8rem; font-weight: 800;
  color: #BE123C; display: flex; align-items: center; gap: .25rem;
  transition: background .15s, transform .1s;
}
.vote-btn:hover:not(:disabled) { background: #FFF1F2; transform: scale(1.08); }
.vote-btn.voted { background: #FFF1F2; border-color: var(--red); }
.vote-btn:disabled { cursor: default; }
.vote-count { font-size: .82rem; }

.gallery-card.vote-winner {
  border: 3px solid var(--yellow) !important;
  box-shadow: 0 0 0 4px rgba(255, 203, 5, .3);
  transform: scale(1.03);
}

.vote-winner-banner {
  background: linear-gradient(135deg, #FFCB05, #FF9900);
  color: var(--dark); font-family: 'Press Start 2P', cursive;
  font-size: .6rem; line-height: 1.8; border-radius: var(--radius-sm);
  padding: .6rem 1rem; text-align: center; width: 100%;
}

/* ─── Fill tool cursor ───────────────────────────────────────────────────────── */
canvas[title="Click to flood-fill"] { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Ctext y='20' font-size='20'%3E🪣%3C/text%3E%3C/svg%3E") 0 20, crosshair; }

/* ─── Streak badges ──────────────────────────────────────────────────────────── */
.streak-badge {
  font-size:.68rem; font-weight:800; color:#EA580C;
  background:#FFF7ED; border:1.5px solid #FED7AA;
  border-radius:50px; padding:.1rem .4rem;
  flex-shrink:0; line-height:1.4;
}
.chat-msg.correct .streak-bonus {
  color:#EA580C; font-weight:800; font-size:.82em;
}

/* ─── Invite-highlight on join card ─────────────────────────────────────────── */
.card-join.invite-highlight {
  border-color: var(--yellow) !important;
  box-shadow: 0 0 0 3px rgba(255,203,5,.35);
  animation: invite-pulse 1s ease 2;
}
@keyframes invite-pulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(255,203,5,.35); }
  50%      { box-shadow: 0 0 0 8px rgba(255,203,5,.1); }
}

/* ─── Loading screen ─────────────────────────────────────────────────────────── */
.screen-loading {
  position: fixed; inset: 0; z-index: 200;
  background: var(--dark);
  display: flex !important; align-items: center; justify-content: center;
}
.screen-loading.hidden { display: none !important; }
.loading-inner { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 1.25rem; }
.loading-logo { display: flex; align-items: center; gap: .75rem; }
.loading-logo img { border-radius: 12px; }
.loading-logo span { font-family: 'Press Start 2P', cursive; font-size: 1rem; color: var(--yellow); line-height: 1.6; }
.loading-msg { font-family: 'Nunito', sans-serif; font-size: .95rem; font-weight: 700; color: #94a3b8; }
.loading-dots { display: flex; gap: .5rem; }
.loading-dots span {
  width: 10px; height: 10px; border-radius: 50%; background: var(--red);
  animation: ldot 1.2s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: .2s; background: var(--yellow); }
.loading-dots span:nth-child(3) { animation-delay: .4s; background: var(--blue); }
@keyframes ldot { 0%,80%,100%{transform:scale(.6);opacity:.4} 40%{transform:scale(1);opacity:1} }

/* ─── Ko-fi widget ───────────────────────────────────────────────────────────── */
.kofi-wrap {
  display: flex; justify-content: center; align-items: center;
  margin-top: .75rem; opacity: .85;
  transition: opacity .2s;
}
.kofi-wrap:hover { opacity: 1; }


/* ─── Browse public rooms ────────────────────────────────────────────────────── */
.browse-section {
  width: 100%; max-width: 720px;
  background: rgba(255,255,255,0.07); border-radius: var(--radius);
  border: 1.5px solid rgba(255,255,255,0.15);
  padding: 1rem 1.25rem; backdrop-filter: blur(4px);
}
.browse-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .75rem;
}
.browse-title {
  font-family: 'Press Start 2P', cursive; font-size: .65rem;
  color: rgba(255,255,255,.85); line-height: 1.6;
}
.btn-browse-refresh {
  background: none; border: 2px solid rgba(255,255,255,.25); border-radius: 50%;
  width: 28px; height: 28px; color: rgba(255,255,255,.7); font-size: 1rem;
  cursor: pointer; transition: transform .3s, border-color .15s; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.btn-browse-refresh:hover { border-color: rgba(255,255,255,.6); color: white; }
.btn-browse-refresh.spinning { animation: spin .6s linear; }
@keyframes spin { to { transform: rotate(360deg); } }
.browse-empty { font-size: .85rem; color: rgba(255,255,255,.5); font-weight: 700; text-align: center; padding: .5rem 0; }
.browse-list { display: flex; flex-direction: column; gap: .5rem; max-height: 200px; overflow-y: auto; }
.browse-row {
  display: flex; align-items: center; gap: .75rem;
  background: rgba(255,255,255,.08); border-radius: var(--radius-sm);
  padding: .6rem .85rem; transition: background .15s;
}
.browse-row:hover { background: rgba(255,255,255,.13); }
.browse-info { flex: 1; display: flex; flex-direction: column; gap: .15rem; }
.browse-host { font-weight: 800; font-size: .88rem; color: white; }
.browse-meta { font-size: .75rem; color: rgba(255,255,255,.55); font-weight: 600; }
.browse-code { font-family: monospace; font-size: 1rem; font-weight: 900; color: var(--yellow); letter-spacing: .1em; flex-shrink: 0; }
.browse-join-btn { flex-shrink: 0; padding: .35rem .9rem !important; font-size: .78rem !important; }

/* ─── Public room toggle ─────────────────────────────────────────────────────── */
.settings-public { margin-top: .25rem; }
.public-toggle {
  display: flex; align-items: flex-start; gap: .6rem;
  background: white; border: 2px solid #E2E8F0; border-radius: var(--radius-sm);
  padding: .6rem .85rem; cursor: pointer; transition: border-color .15s, background .15s;
  font-size: .88rem; font-weight: 700; user-select: none;
}
.public-toggle:hover { border-color: var(--blue); background: #f0f4ff; }
.public-toggle input[type="checkbox"] { accent-color: var(--blue); width: 15px; height: 15px; cursor: pointer; flex-shrink: 0; margin-top: 2px; }
.public-toggle input[type="checkbox"]:checked ~ .public-toggle-label { color: var(--blue); }
.public-toggle-label { display: flex; flex-direction: column; gap: .1rem; line-height: 1.3; }
.public-toggle-label em { display: block; font-style: normal; font-size: .72rem; color: var(--mid); font-weight: 600; }

/* ─── LoL mode theme overrides ───────────────────────────────────────────────── */
body.mode-lol { --red: #C89B3C; --blue: #0BC4E3; --yellow: #C89B3C; }
body.mode-lol .btn-create          { background: #0BC4E3; }
body.mode-lol .btn-create:hover    { background: #09a8c3; }
body.mode-lol .word-choice-btn     { border-color: #C89B3C; }
body.mode-lol .word-choice-btn:hover { background: #C89B3C; }
body.mode-lol .game-topbar         { border-bottom-color: #C89B3C; }
body.mode-lol .overlay-box         { border-top-color: #C89B3C; }
body.mode-lol .guess-wrap input:focus { border-color: #0BC4E3; }
body.mode-lol #draw-canvas         { border-color: #1a1a2e; }

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — TABLET (≤900px)
═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  /* Collapse left player sidebar — shown via toggle button instead */
  .sidebar-left { display: none; }
  .sidebar-left.mob-open {
    display: flex;
    position: fixed; top: 56px; left: 0; bottom: 0; z-index: 80;
    width: 200px; box-shadow: 4px 0 20px rgba(0,0,0,.25);
  }

  /* Player toggle button — only visible on tablet/mobile */
  #mob-players-btn {
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; color: white; font-size: 1.2rem;
    padding: .4rem .6rem; cursor: pointer; border-radius: 6px;
    transition: background .15s;
  }
  #mob-players-btn:hover { background: rgba(255,255,255,.12); }

  /* Backdrop for open player sidebar */
  #mob-sidebar-backdrop {
    display: none; position: fixed; inset: 0; z-index: 79;
    background: rgba(0,0,0,.4);
  }
  #mob-sidebar-backdrop.visible { display: block; }

  /* Shrink topbar text */
  .round-label   { font-size: .5rem; }
  .word-display  { font-size: .8rem; min-width: 120px; letter-spacing: .15em; }
  .timer-ring    { width: 38px; height: 38px; font-size: .65rem; }
  .game-topbar   { padding: 0 .75rem; height: 50px; gap: .5rem; }

  /* Narrow chat sidebar */
  .sidebar-right { width: 200px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — PHONE PORTRAIT (≤600px)
═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {

  /* ── Game screen vertical stack ── */
  #screen-game   { height: 100dvh; height: 100vh; }
  .game-main     { flex-direction: column; overflow: hidden; }

  /* Left sidebar: same slide-in as tablet */
  .sidebar-right { width: 100%; flex-direction: row; height: auto; flex-shrink: 0; }

  /* Canvas area takes available vertical space above chat */
  .game-center {
    flex: 1; padding: .25rem; gap: .25rem;
    min-height: 0; overflow: hidden;
  }
  .canvas-wrapper { flex: 1; min-height: 0; }

  /* Chat bar at bottom — compact row when collapsed */
  .sidebar-right { display: flex; flex-direction: column; max-height: 40vh; flex-shrink: 0; }
  .chat-log      { flex: 1; min-height: 60px; }

  /* Toolbar scrolls horizontally, no wrapping */
  .draw-toolbar {
    flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden;
    border-radius: 8px; padding: .35rem .75rem; gap: .5rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .draw-toolbar::-webkit-scrollbar { display: none; }
  .toolbar-section { flex-shrink: 0; }
  .toolbar-section + .toolbar-section { border-left: 1.5px solid var(--light); padding-left: .5rem; }

  /* Smaller color swatches on mobile */
  .color-swatch  { width: 20px; height: 20px; }
  .color-palette { gap: 4px; max-width: none; flex-wrap: nowrap; }

  /* Topbar compressed */
  .game-topbar   { height: 44px; padding: 0 .5rem; gap: .3rem; }
  .round-label   { font-size: .42rem; }
  .word-display  { font-size: .7rem; min-width: 80px; letter-spacing: .1em; }
  .timer-ring    { width: 34px; height: 34px; font-size: .58rem; }
  .topbar-left   { min-width: 0; }

  /* Overlay boxes smaller on phone */
  .overlay-box   { padding: 1.25rem; gap: .75rem; }
  .overlay-box h3 { font-size: .75rem; }
  .word-choice-btn { font-size: .65rem; padding: .75rem 1rem; }

  /* Game-over gallery 2-col grid on phone */
  .drawing-gallery { grid-template-columns: repeat(2, 1fr) !important; gap: .5rem !important; }
  .gameover-box { padding: 1rem; }

  /* Guess input bigger tap target */
  .chat-input-row { padding: .4rem; gap: .3rem; }
  .chat-input-row button { width: 40px; height: 40px; }
  .guess-wrap input { padding: .6rem .75rem; font-size: .9rem; }

  /* ── Home & Lobby ── */
  .home-wrapper  { gap: 1.25rem; padding: 1rem; }
  .home-cards    { gap: 1rem; }
  .home-card     { padding: 1.4rem 1.2rem; }
  .home-logo h1  { font-size: 1.4rem; }
  .home-logo p   { font-size: .85rem; }

  .lobby-panel   { padding: 1.5rem 1.2rem; }
  .room-code     { font-size: 1.1rem; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-gens { flex-direction: column; }
  .gen-checkbox  { min-width: 0; }

  /* Avatar modal smaller */
  .avatar-modal  { padding: 1.25rem; }
  .avatar-canvas-wrap canvas { width: 160px !important; height: 160px !important; }

  /* Bug/feedback modal */
  .bug-modal     { padding: 1.25rem; max-width: 95vw; }

  /* Browse section */
  .browse-section { padding: .75rem 1rem; }
  .browse-row     { flex-wrap: wrap; gap: .4rem; }

  /* Ko-fi */
  .kofi-wrap { margin-top: .5rem; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Hide desktop-only elements on mobile
═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  /* The player list toggle button is injected by JS — hidden on desktop */
  #mob-players-btn { display: flex; }
}
@media (min-width: 901px) {
  #mob-players-btn { display: none !important; }
  #mob-sidebar-backdrop { display: none !important; }
}
