/* The universal game shell: menu, lobby, turn banner, timers, settings drawer, log and chat.
   Each game draws only its own board inside #board. */
.game { display: flex; flex-direction: column; gap: 14px; max-width: 880px; }
.game > * { margin: 0; }
.g-loading, .g-empty { color: var(--dim); }

/* form bits shared by the menu and the settings drawer */
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.field > span { font-size: 15px; }
.field small { display: block; color: var(--dim); font-size: 12px; }
.stepper { display: flex; align-items: center; gap: 2px; flex: none; }
.stepper button { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--raised); color: var(--text); font: 600 20px/1 var(--sans); cursor: pointer; }
.stepper button:disabled { opacity: .35; cursor: default; }
.stepper output { min-width: 56px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.game select, .game input[type="text"], .drawer select, .drawer input[type="text"] {
  min-height: 44px; max-width: 100%; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--raised); color: var(--text); font: 16px var(--sans);
}
.game select, .drawer select { padding-right: 8px; }
.drawer fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.drawer fieldset:disabled { opacity: .5; }
.card-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.count-box { padding: 6px 12px 6px 16px; }
.page .card-box h2 { margin: 0 0 10px; }
.btn.big { min-height: 52px; padding: 0 24px; font-size: 16px; }
.btn.danger { background: none; color: var(--red); border-color: #5a3030; }
.btn.danger.armed, .btn.danger:hover { background: var(--red); color: #141919; border-color: var(--red); }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* menu */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.join-form { display: flex; gap: 8px; }
.name-form { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.name-form input { flex: 1 1 180px; min-width: 0; font-size: 18px !important; }
.gate { max-width: 520px; }
.gate .mono { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .15em; }
.join-form input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: .3em; font: 600 20px ui-monospace, Menlo, Consolas, monospace !important; text-align: center; }

/* room header */
.g-top { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; }
.page .g-top h1 { margin: 0; font-size: clamp(22px, 5vw, 30px); }
.badge { display: inline-block; margin-left: 8px; padding: 3px 10px; border-radius: 999px; font: 600 11px/1.4 var(--sans); letter-spacing: .1em; text-transform: uppercase; vertical-align: middle; background: var(--raised); color: var(--dim); }
.badge.PLAYING { background: #17382a; color: var(--green); } .badge.PAUSED { background: #3a3016; color: #ffcf8a; } .badge.FINISHED { background: #2c2440; color: #c9b8ff; }
.code-btn { min-height: 44px; padding: 0 14px; border-radius: 10px; border: 1px dashed var(--line); background: none; color: var(--dim); cursor: pointer; font: 13px var(--sans); }
.code-btn b { margin-left: 6px; color: var(--text); font: 700 18px ui-monospace, Menlo, Consolas, monospace; letter-spacing: .18em; }
.g-conn { padding: 8px 12px; border-radius: 8px; background: #3a3016; color: #ffcf8a; font-size: 14px; }

/* banner: whose turn, the clock, the result */
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--c, var(--line)); }
.banner strong { flex: 1; min-width: 0; font-size: 17px; overflow-wrap: anywhere; }
.banner.mine { background: #17382a; border-color: var(--green); }
.banner .clock { flex: none; font: 700 18px ui-monospace, Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
.banner .clock.low { color: var(--red); }
.scoreline { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; color: var(--dim); }
.scoreline span { display: inline-flex; align-items: center; gap: 6px; }
.scoreline .out { text-decoration: line-through; opacity: .6; }
.scoreline b { color: var(--text); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; display: inline-block; }
.rules-line { color: var(--dim); font-size: 14px; }

/* teams */
.teams { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 10px; }
.team { background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--c); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.team.turn { box-shadow: 0 0 0 1px var(--c); }
.team.out { opacity: .55; }
.team header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.team header strong { overflow-wrap: anywhere; }
.team header small { color: var(--dim); white-space: nowrap; }
.team header .seat { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.team ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.member { display: flex; align-items: center; gap: 8px; min-height: 44px; min-width: 0; }
.member .face { width: 30px; height: 30px; font-size: 13px; flex: none; }
.member .face.bot { background: var(--raised); color: var(--text); border: 1px solid var(--line); }
.member .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.member .nm small { color: var(--dim); margin-left: 6px; font-size: 12px; }
.member.off .nm { opacity: .5; }
.member select { flex: none; width: 108px; font-size: 16px; }
.team .none { color: var(--dim); font-size: 14px; min-height: 44px; display: flex; align-items: center; }
.team .btn { font-size: 13px; padding: 0 12px; }

/* the board area */
.stage { position: relative; display: flex; justify-content: center; }
#board { width: 100%; display: flex; justify-content: center; }
.emotes { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.emotes span { position: absolute; bottom: 10%; font-size: 40px; animation: floatup 1.9s ease-out forwards; }
@keyframes floatup { from { transform: translateY(0) scale(.6); opacity: 0; } 15% { opacity: 1; transform: translateY(-20px) scale(1.1); } to { transform: translateY(-180px) scale(1); opacity: 0; } }

/* log + chat */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { min-height: 44px; padding: 0 16px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--dim); font: 600 14px var(--sans); cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--text); border-color: var(--green); }
.tabs .count { margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: var(--green); color: #141919; font-size: 11px; }
.feed { list-style: none; margin: 0; padding: 8px 0; max-height: 260px; overflow-y: auto; display: grid; gap: 6px; font-size: 14px; overscroll-behavior: contain; }
.feed li { overflow-wrap: anywhere; color: #d5dddd; }
.feed time { color: var(--dim); font-size: 12px; margin-right: 8px; font-variant-numeric: tabular-nums; }
.feed .result { color: var(--green); font-weight: 600; } .feed .timeout { color: #ffcf8a; }
.feed b { color: var(--c, var(--text)); margin-right: 6px; }
.feed .emo { font-size: 22px; vertical-align: middle; }
.emote-row { display: flex; gap: 4px; flex-wrap: wrap; }
.emote-row button { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--raised); font-size: 20px; cursor: pointer; }
.chat-form { display: flex; gap: 8px; margin-top: 8px; }
.chat-form input { flex: 1; min-width: 0; }
.chat-note { color: var(--dim); font-size: 14px; margin: 8px 0 0; }

/* settings drawer */
.drawer-back { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .6); }
.drawer { position: fixed; z-index: 60; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); font-family: var(--sans); }
.drawer header { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 18px; border-bottom: 1px solid var(--line); }
.drawer header strong { font-size: 17px; }
.drawer .body { flex: 1; overflow-y: auto; padding: 4px 18px 18px; overscroll-behavior: contain; }
.drawer h3 { margin: 18px 0 4px; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.drawer .note { color: var(--dim); font-size: 13px; margin: 0 0 6px; }
.drawer footer { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.drawer footer .btn { flex: 1; }
.team-edit { display: grid; gap: 6px; padding: 8px 0; border-top: 1px solid var(--line); }
.team-edit input { width: 100%; }
.swatches { display: flex; flex-wrap: wrap; gap: 2px; }
.swatches button { width: 44px; height: 44px; padding: 0; border: 0; background: none; cursor: pointer; display: grid; place-items: center; }
.swatches i { width: 26px; height: 26px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px var(--panel); }
.swatches button[aria-pressed="true"] i { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px #fff; }
.swatches button:disabled { opacity: .25; cursor: default; }

.toast { position: fixed; left: 50%; bottom: 20px; z-index: 80; transform: translateX(-50%); max-width: min(92vw, 480px); padding: 12px 16px; border-radius: 10px; background: #2a1f1f; border: 1px solid #5a3030; color: #ffd0d0; font: 14px var(--sans); box-shadow: 0 8px 24px rgba(0, 0, 0, .5); }
.toast.ok { background: #17382a; border-color: #2f5a45; color: #d6ffe6; }

@media (max-width: 480px) {
  .stage { margin-inline: -12px; }   /* give boards the full width of a phone */
  .card-box { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) { .emotes span { animation-duration: .01s; } }
