/* Look from prototype/game-prototype.dc.html: cream tiles, banana background. */
:root {
  --bg: #FFF4CC; --ink: #2A2010; --muted: #6B5A33; --accent: #F5C518;
  --tile: #FBF5E6; --tile-edge: #D9CBA6; --line: #EAD9A0; --field: #C9B98C; --soft: #FFE88A;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: Nunito, system-ui, sans-serif; }
a { color: var(--ink); } a:hover { color: #000; }
button { font-family: Nunito, sans-serif; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); margin: 0; }

.page { min-height: 100vh; padding: 28px 20px 56px; }
.wrap { max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }

/* title centred; in-game controls on the right (below the title on narrow screens) */
header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.logo { grid-column: 2; margin: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.head-right { grid-column: 3; justify-self: end; }
@media (max-width: 980px) {
  header { grid-template-columns: 1fr; justify-items: center; }
  .logo, .head-right { grid-column: 1; justify-self: center; }
}
.logo span {
  width: 38px; height: 42px; display: flex; align-items: center; justify-content: center;
  background: var(--tile); border-radius: 7px; box-shadow: 0 3px 0 var(--tile-edge), 0 5px 8px rgba(42,32,16,.18);
  font: 700 24px Fredoka, sans-serif; color: #1A1A1A;
}
.head-right { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; }
.pill-code { padding: 8px 14px; border-radius: 999px; background: #fff; border: 2px solid var(--line); font-weight: 800; font-size: 14px; }

/* buttons */
.btn { min-height: 50px; padding: 0 20px; border-radius: 999px; border: 2px solid var(--ink); background: #fff; color: var(--ink); font-weight: 800; font-size: 16px; cursor: pointer; }
.btn.sm { min-height: 44px; padding: 0 18px; font-size: 14px; font-weight: 700; }
.btn.primary { border: 0; background: var(--accent); box-shadow: 0 4px 0 var(--ink); padding: 0 26px; }
.btn.primary:disabled { background: #E5DDC4; cursor: default; }
.btn.ghost { min-height: 40px; padding: 0 16px; background: transparent; font-size: 13px; font-weight: 700; }
.btn:active:not(:disabled) { transform: translateY(1px); }

/* cards (home, settings, lobby) */
.card {
  align-self: center; width: 100%; max-width: 640px; background: #fff; border: 2px solid var(--ink);
  border-radius: 22px; box-shadow: 0 6px 0 var(--ink); padding: 28px; display: flex; flex-direction: column; gap: 22px;
}
.card.narrow { max-width: 440px; gap: 18px; }
.card h2 { margin: 0; font: 700 28px Fredoka, sans-serif; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, legend, .label { font-weight: 800; font-size: 15px; }
.input {
  min-height: 50px; padding: 0 16px; border: 2px solid var(--field); border-radius: 14px;
  font: 600 20px Fredoka, sans-serif; color: var(--ink); background: #FFFDF5; width: 100%; min-width: 0;
}
.input.code { font-weight: 700; font-size: 22px; letter-spacing: .3em; text-transform: uppercase; }
.row { display: flex; gap: 8px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; font-weight: 700; }
.or::before, .or::after { content: ''; flex: 1 1 auto; height: 2px; background: var(--line); }
.err { margin: 0; padding: 10px 14px; border-radius: 12px; background: #FDE2DD; color: #8F1B1B; font-weight: 600; font-size: 15px; }
.ok { background: #E3F3DF; color: #1E5E34; }

fieldset { margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: 8px; }
legend { padding: 0; margin-bottom: 8px; font-size: 16px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { display: flex; gap: 8px; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 2px solid var(--line); background: #fff; cursor: pointer; font-weight: 700; }
.opt.big { align-items: flex-start; padding: 12px 14px; border-radius: 14px; gap: 10px; }
.opt.on { border-color: var(--ink); background: var(--bg); }
.opt input, .check input { margin: 0; width: 18px; height: 18px; accent-color: var(--ink); flex: none; }
.opt.big input, .check input { margin-top: 3px; }
.opt .desc { display: block; font-size: 14px; color: var(--muted); font-weight: 400; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check .ex { color: var(--muted); }
select.input { align-self: flex-start; width: auto; min-height: 44px; font: 700 15px Nunito, sans-serif; border-radius: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; align-items: center; }

/* lobby */
.lobby-code { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.lobby-code h2 { font: 800 14px Nunito, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.code-tiles { display: flex; gap: 8px; }
.code-tiles span {
  width: 60px; height: 66px; display: flex; align-items: center; justify-content: center; background: var(--tile);
  border-radius: 10px; box-shadow: 0 0 0 1px var(--tile-edge), 0 5px 0 var(--tile-edge), 0 8px 12px rgba(42,32,16,.2);
  font: 700 38px Fredoka, sans-serif; color: #1A1A1A;
}
.invite-text { margin: 0; font-size: 14px; user-select: all; padding: 8px 12px; border-radius: 10px; background: var(--bg); word-break: break-all; }
.card h3 { margin: 0; font: 700 20px Fredoka, sans-serif; }
.people { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.people li { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: #fff; border: 2px solid var(--line); font-weight: 800; }
.people li.me { background: var(--bg); }
.people li.off { opacity: .5; }
.people li.add { padding: 0; border-style: dashed; background: transparent; }
.people li.add button { min-height: 40px; padding: 0 14px; border: 0; background: none; font-weight: 800; font-size: 15px; color: var(--muted); cursor: pointer; border-radius: 999px; }
.chip-x { margin: -4px -6px -4px 0; width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--line); color: var(--ink); font-size: 16px; font-weight: 800; line-height: 1; cursor: pointer; }
legend .ex, .label .ex { font-weight: 400; color: var(--muted); font-size: 14px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--ink); color: var(--bg); }
.settings-list { margin: 0; padding: 0 0 0 20px; display: flex; flex-direction: column; gap: 4px; font-size: 15px; }
.waiting { margin: 0; font-weight: 700; color: var(--muted); }

/* game */
.game { display: flex; flex-direction: column; gap: 24px; }
.over { background: var(--ink); color: var(--bg); border-radius: 18px; padding: 18px 22px; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; }
.over b { font: 700 26px Fredoka, sans-serif; }
.over span { font-size: 16px; }
main { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.tiles { width: 100%; max-width: 760px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.bag { position: relative; width: 100%; max-width: 560px; height: 170px; }
.bag div {
  position: absolute; width: 20px; height: 22px; border-radius: 4px; background: #F1E6C8;
  box-shadow: 0 0 0 1px var(--tile-edge), 0 2px 0 #CDBD93, 0 3px 5px rgba(42,32,16,.25);
}
.pool { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; min-height: 56px; }
.pool div {
  width: 48px; height: 52px; display: flex; align-items: center; justify-content: center; background: var(--tile);
  border-radius: 8px; box-shadow: 0 4px 0 var(--tile-edge), 0 6px 10px rgba(42,32,16,.25);
  font: 700 28px Fredoka, sans-serif; color: #1A1A1A;
}
.pool div.new { box-shadow: 0 4px 0 var(--accent), 0 6px 10px rgba(42,32,16,.25); animation: pop .25s ease-out; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.turn { margin: 0; padding: 6px 14px; border-radius: 999px; font-size: 14px; font-weight: 700; color: var(--muted); }
.turn.mine { background: var(--accent); color: var(--ink); }

.claim { width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 10px; }
.stealing { margin: 0; font-size: 14px; text-align: center; }
.bar { display: flex; gap: 8px; background: #fff; padding: 6px; border-radius: 999px; border: 2px solid var(--ink); box-shadow: 0 4px 0 var(--ink); }
.bar input {
  flex: 1 1 auto; min-width: 0; min-height: 46px; padding: 0 16px; border: 0; border-radius: 999px; outline-offset: 2px;
  font: 600 22px Fredoka, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--ink); background: transparent;
}
.bar:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.bar input:focus { outline: none; }
.bar input::placeholder { text-transform: none; letter-spacing: 0; font-size: 18px; }
.bar button { flex: 0 0 auto; min-height: 46px; padding: 0 22px; border-radius: 999px; border: 0; background: var(--accent); color: var(--ink); font-weight: 800; font-size: 16px; cursor: pointer; }
.msg { margin: 0; padding: 10px 14px; border-radius: 12px; font-size: 15px; font-weight: 600; text-align: center; background: #FDE2DD; color: #8F1B1B; }
.msg.ok { background: #E3F3DF; color: #1E5E34; }

.table { display: flex; flex-direction: column; gap: 16px; }
.table > h2 { margin: 0; font: 700 24px Fredoka, sans-serif; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.player { background: #fff; border: 2px solid var(--line); border-radius: 18px; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 4px 0 var(--line); }
.player.flipping { border-color: var(--accent); box-shadow: 0 4px 0 var(--accent); }
.player.off h3 { opacity: .5; }
.player-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.player-head > div { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.player h3 { margin: 0; font: 700 22px Fredoka, sans-serif; }
.badge { font-size: 12px; font-weight: 800; padding: 3px 9px; border-radius: 999px; background: var(--accent); color: var(--ink); }
.badge.dim { background: var(--line); color: var(--muted); }
.score { font: 700 26px Fredoka, sans-serif; }
.score small { font-size: 14px; font-weight: 600; color: var(--muted); }
.words { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; }
.word { display: flex; align-items: center; gap: 8px; padding: 6px 10px 9px 6px; border-radius: 12px; border: 2px solid transparent; background: transparent; cursor: pointer; font: inherit; color: inherit; }
.word:disabled { cursor: default; }
.word.on { border-color: var(--ink); background: var(--soft); }
.word > span:first-child { display: flex; flex-wrap: wrap; gap: 4px; }
.word .l {
  width: 36px; height: 40px; display: flex; align-items: center; justify-content: center; background: var(--tile);
  border-radius: 6px; box-shadow: 0 3px 0 var(--tile-edge), 0 5px 6px rgba(42,32,16,.15); font: 700 22px Fredoka, sans-serif; color: #1A1A1A;
}
.word .pts { font-size: 13px; font-weight: 800; color: var(--muted); }

.log { display: flex; flex-direction: column; gap: 8px; padding: 4px 2px; }
.log h2 { margin: 0; font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.log ol { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.log li { font-size: 14px; line-height: 1.4; padding: 8px 12px; border-radius: 10px; background: #fff; }
.log li:first-child { background: var(--soft); font-weight: 700; }

.offline { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); padding: 8px 16px; border-radius: 999px; background: var(--ink); color: var(--bg); font-weight: 700; font-size: 14px; z-index: 5; }

@media (max-width: 520px) {
  .page { padding: 18px 12px 40px; }
  .logo span { width: 28px; height: 32px; font-size: 18px; }
  .card { padding: 20px; }
  .grid { grid-template-columns: 1fr; }
  .pool div { width: 40px; height: 44px; font-size: 24px; }
  .word .l { width: 30px; height: 34px; font-size: 19px; }
  .bag { height: 130px; }
}
