:root {
  color-scheme: light;
  --ink: #20352c;
  --muted: #88928a;
  --green: #245c45;
  --green-dark: #194733;
  --paper: #f5f4ee;
  --line: #e9e9e1;
  --tile: #e9c987;
  font-family: "DM Sans", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); }
button, input { font: inherit; }
button { color: inherit; }
.game-shell { max-width: 1800px; min-height: 100vh; margin: 0 auto; padding: 0 2.5%; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font: 800 17px "Manrope", sans-serif; letter-spacing: -.8px; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: var(--green); color: #fff7e7; font: 800 16px Georgia, serif; transform: rotate(-5deg); }
.brand-dot { color: #d6984d; }
.live-dot, .turn-dot { width: 7px; height: 7px; border-radius: 50%; background: #71a37c; box-shadow: 0 0 0 3px #e3ede2; }
.top-actions { display: flex; align-items: center; gap: 13px; }
.icon-button, .avatar { border: 0; cursor: pointer; }
.icon-button { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 50%; background: transparent; color: #557064; transition: background .2s; }
.icon-button:hover { background: #e9ece4; }
.icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.avatar { width: 33px; height: 33px; border-radius: 50%; background: #dca979; color: white; font: 700 13px "Manrope", sans-serif; }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 292px; gap: clamp(22px, 3vw, 48px); padding: 0 0 32px; align-items: start; }
.play-column { min-width: 0; }
.board-stage { min-width: 0; }
.board-stage > .board-frame { min-width: 0; }
.turn-panel { display: flex; flex-direction: column; align-items: stretch; gap: 12px; margin-top: 16px; }
.turn-status-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; min-width: 0; }
.turn-panel .eyebrow { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.turn-panel .eyebrow strong { color: #536254; font: 700 10px "Manrope", sans-serif; letter-spacing: 0; }
.turn-status-row > strong { min-width: 0; color: var(--green); font: 700 14px "Manrope", sans-serif; line-height: 1.4; overflow-wrap: anywhere; text-align: right; }
.turn-panel .word-score-preview { flex-direction: row; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid #efefe8; border-bottom: 1px solid #efefe8; }
.turn-tools { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.turn-tools .quiet-button, .turn-tools .play-button { width: 100%; min-width: 0; justify-content: center; margin: 0; }
.turn-tools #undoWordButton[hidden] { display: none; }
.turn-tools .play-button { gap: 12px; }
.eyebrow { color: #92988d; font-size: 9px; line-height: 1.5; font-weight: 700; letter-spacing: 1.45px; }
h1, h2 { margin: 0; font-family: "Manrope", sans-serif; }
h1 { margin-top: 12px; color: #223b30; font-size: clamp(25px, 2.8vw, 36px); font-weight: 600; line-height: 1.22; letter-spacing: -1.6px; }
.quiet-button { display: flex; align-items: center; gap: 7px; margin-bottom: 3px; padding: 9px 12px; border: 1px solid #e4e6dc; border-radius: 8px; background: transparent; color: #627268; font-size: 11px; font-weight: 600; cursor: pointer; transition: background .2s, border-color .2s; }
.quiet-button:hover { border-color: #cbd6c8; background: #eff1e9; }
.quiet-button span { font-size: 16px; }
.mobile-break { display: none; }
.board-frame { padding: 8px; border: 1px solid #e8e5d9; border-radius: 11px; background: #eeece2; box-shadow: 0 4px 18px #3a49300a; }
.board-scroll { overflow-x: auto; padding: 0 0 3px; scrollbar-color: #c3c7b9 transparent; scrollbar-width: thin; }
.board { width: min(100%, 1000px, max(220px, calc(100dvh - 160px))); aspect-ratio: 1; display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 3px; margin: 0 auto; }
.square { min-width: 0; aspect-ratio: 1; position: relative; overflow: hidden; display: grid; place-items: center; padding: 0; border: 0; border-radius: 3px; background-color: #e3dfd1; background-position: center; background-size: 100% 100%; cursor: pointer; transition: filter .12s, transform .12s; }
.square:hover { filter: brightness(1.05); z-index: 1; }
.square:focus-visible { outline: 2px solid #285a44; outline-offset: 1px; z-index: 2; }
.square.center-square { background-color: #e2d7bd; }
.square.tile-on-board { background-color: #e9c987; box-shadow: 0 2px 3px #47371d2e; }
.square.tile-on-board img { width: 100%; height: 100%; object-fit: cover; }
.square.is-new-tile { outline: 3px solid #3f814e; outline-offset: -3px; }
.square.word-played { z-index: 3; outline: 3px solid #3f814e; outline-offset: -3px; animation: word-played-flash 1s ease-in-out 5; animation-delay: var(--played-animation-delay, 0ms); }
@keyframes word-played-flash {
  0%, 100% { outline-color: #3f814e; filter: brightness(1); }
  50% { outline-color: transparent; filter: brightness(1.35); }
}
.square.is-new-tile[draggable="true"] { cursor: grab; }
.board-coordinates { display: flex; justify-content: space-between; padding-top: 9px; color: #99998d; font-size: 8px; font-weight: 700; letter-spacing: 1.15px; }
.rack-panel { margin-top: 17px; padding: 0 2px; }
.rack { --rack-tile-size: clamp(39px, 5vw, 54px); position: relative; min-height: clamp(76px, 9vh, 96px); margin: 0 0 13px; overflow: hidden; border: 1px solid #e8e5d9; border-radius: 9px; background: #eeece2; touch-action: manipulation; }
.rack-tile { position: absolute; display: block; width: var(--rack-tile-size); height: var(--rack-tile-size); padding: 0; border: 0; border-radius: 5px; background: #e9c987; box-shadow: 0 3px 4px #6553331c, 0 1px 0 #fff8e6 inset; cursor: grab; line-height: 0; transition: transform .15s, box-shadow .15s; }
.rack-tile img { display: block; width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.rack-tile:hover { transform: translateY(-3px); }
.rack-tile.selected { transform: translateY(-6px); box-shadow: 0 0 0 2px #4b7a56, 0 5px 9px #29452c2c; }
.rack-tile.exchange-selected { transform: translateY(-5px); box-shadow: 0 0 0 2px #c08048, 0 5px 9px #62411f2c; }
.rack-tile.dragging { opacity: .4; }
.rack-tile.rack-tile-placed { box-shadow: 0 2px 4px #6553331c, 0 0 0 1px #c9c4b4; }
.word-score-preview { display: flex; flex-direction: column; gap: 3px; flex: 0 0 auto; color: #858b80; font-size: 9px; }
.word-score-preview strong { color: #245c45; font: 700 17px "Manrope", sans-serif; }
.play-button { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-width: 135px; padding: 11px 13px 11px 16px; border: 0; border-radius: 7px; background: var(--green); color: white; font-size: 11px; font-weight: 600; cursor: pointer; box-shadow: 0 3px 6px #244e3821; transition: background .2s, transform .2s; }
.play-button:hover:not(:disabled) { transform: translateY(-1px); background: var(--green-dark); }
.play-button:disabled { opacity: .45; cursor: not-allowed; }
.turn-tools button:disabled { opacity: .45; cursor: not-allowed; }
.room-share { display: flex; align-items: center; gap: 8px; margin-top: 11px; padding-top: 10px; border-top: 1px solid #efefe8; color: #92958b; font-size: 9px; }
.room-share strong { flex: 1; color: #435b49; font: 700 11px "Manrope", sans-serif; letter-spacing: 1px; }
.copy-room-button { padding: 5px 8px; border: 1px solid #e5e7dd; border-radius: 5px; background: transparent; color: #647568; font-size: 9px; cursor: pointer; }
.copy-room-button:hover { background: #edf0e7; }
.statistics-dialog { width: min(94vw, 620px); max-height: min(82vh, 760px); padding: 22px; border: 1px solid #e8e8df; border-radius: 12px; background: #fbfaf6; color: #43564a; box-shadow: 0 24px 80px #10201555; }
.statistics-dialog::backdrop { background: #17241d99; backdrop-filter: blur(3px); }
.statistics-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.statistics-heading h2 { margin-top: 4px; color: #263d31; font-size: 20px; }
.statistics-close { width: 30px; height: 30px; border: 1px solid #e5e7dd; border-radius: 6px; background: #fffefa; color: #647568; font-size: 20px; cursor: pointer; }
.statistics-summary { margin: 14px 0; color: #858b80; font-size: 11px; }
.statistics-list { display: grid; gap: 9px; max-height: 58vh; overflow-y: auto; }
.statistics-empty { padding: 25px 10px; border: 1px dashed #e2e4da; border-radius: 8px; color: #92958b; font-size: 11px; text-align: center; }
.statistics-game { padding: 12px; border: 1px solid #e8e8df; border-radius: 8px; background: #fffefa; }
.statistics-game-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.statistics-game-heading strong { color: #435b49; font: 700 11px "Manrope", sans-serif; letter-spacing: .5px; }
.statistics-game-heading span, .statistics-game-date { color: #92958b; font-size: 9px; }
.statistics-game-date { margin-top: 4px; }
.statistics-players { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.statistics-player { padding: 5px 7px; border-radius: 5px; background: #f0efe6; color: #647568; font-size: 9px; }
.statistics-player.winner { background: #e6eee3; color: #557457; font-weight: 700; }
.join-overlay { position: fixed; z-index: 10; inset: 0; display: grid; place-items: center; padding: 18px; background: #17241dd9; backdrop-filter: blur(5px); }
.join-overlay[hidden] { display: none; }
.join-card { width: min(100%, 430px); max-height: min(92vh, 760px); overflow-y: auto; padding: 30px; border: 1px solid #e8e8df; border-radius: 16px; background: #fbfaf6; box-shadow: 0 24px 80px #10201555; }
.join-mark { margin-bottom: 22px; }
.join-card h2 { margin-top: 7px; color: #263d31; font-size: 25px; letter-spacing: -.8px; }
.join-card p { margin: 8px 0 20px; color: #83887d; font-size: 12px; line-height: 1.65; }
.join-card label { display: block; margin: 14px 0 6px; color: #526357; font-size: 10px; font-weight: 700; }
.join-card label span { color: #a4a69b; font-weight: 400; }
.join-card input, .join-card select { width: 100%; padding: 11px 12px; border: 1px solid #e4e6dc; border-radius: 7px; outline: 0; background: #fffefa; color: #43564a; font-size: 12px; }
.join-card input:focus, .join-card select:focus { border-color: #9eb69f; box-shadow: 0 0 0 3px #dce8dd; }
.join-buttons { display: flex; gap: 9px; margin-top: 20px; }
.join-action { flex: 1; justify-content: center; margin: 0; }
#createRoomButton[hidden] { display: none; }
.join-error { min-height: 17px; margin-top: 10px; color: #ad3026; font-size: 10px; font-weight: 700; }
.co-player-setup { margin-top: 7px; padding: 12px; border: 1px solid #e8e8df; border-radius: 8px; background: #f5f4ee; }
.co-player-setup[hidden] { display: none; }
.co-player-fields { display: grid; gap: 8px; margin-top: 8px; }
.co-player-fields input { padding: 9px 10px; }
.setup-note { margin-top: 9px; color: #858b80; font-size: 10px; line-height: 1.5; }
.button-arrow { font-size: 16px; font-weight: 400; }
.sidebar { padding-top: 0; }
.side-card { padding: 20px 19px; border: 1px solid #e8e8df; border-radius: 11px; background: #fbfaf6; }
.score-card { padding-bottom: 13px; }
.card-heading { display: flex; align-items: center; justify-content: space-between; }
.card-heading h2 { margin-top: 4px; color: #263d31; font-size: 17px; font-weight: 600; letter-spacing: -.5px; }
.round-badge { display: flex; align-items: center; gap: 5px; padding: 5px 7px; border: 0; border-radius: 4px; background: #f0efe6; color: #77786e; font-size: 8px; font-weight: 700; letter-spacing: .8px; cursor: pointer; }
.round-badge:hover { background: #e8ebdf; }
.bag-distribution { margin: 12px 0; padding: 10px; border: 1px solid #eeeee7; border-radius: 8px; background: #f7f6f0; }
.bag-distribution[hidden] { display: none; }
.bag-distribution-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; color: #82867b; font-size: 9px; }
.bag-distribution-title strong { color: #526757; font: 700 11px "Manrope", sans-serif; }
.bag-distribution-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.bag-letter-count { min-height: 31px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid #e7e5d9; border-radius: 4px; background: #fffefa; }
.bag-letter-count strong { color: #536254; font: 700 10px "Manrope", sans-serif; }
.bag-letter-count span { margin-top: 1px; color: #96998d; font-size: 8px; }
.player-list { margin-top: 17px; }
.player-row { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-top: 1px solid #efefe8; }
.player-row:first-child { border-top: 0; }
.player-avatar { width: 32px; height: 32px; flex: 0 0 32px; display: grid; place-items: center; border-radius: 50%; color: #fff; font: 700 11px "Manrope", sans-serif; }
.player-info { min-width: 0; flex: 1; }
.player-name { overflow: hidden; color: #4a594d; font-size: 11px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.player-status { margin-top: 2px; color: #a0a297; font-size: 9px; }
.player-score { color: #273f32; font: 700 15px "Manrope", sans-serif; }
.player-row.active .player-name { color: var(--green); }
.player-row.active .player-status { color: #709074; }
.playing-pill { margin-left: 5px; padding: 2px 5px; border-radius: 4px; background: #e6eee3; color: #557457; font-size: 7px; font-weight: 700; letter-spacing: .4px; vertical-align: 1px; }
.admin-badge { margin-left: 5px; padding: 2px 5px; border-radius: 4px; background: #f3eadb; color: #9a7043; font-size: 7px; font-weight: 700; letter-spacing: .4px; vertical-align: 1px; }
.add-player-button { width: 100%; display: flex; align-items: center; gap: 8px; margin-top: 6px; padding: 10px 0 0; border: 0; border-top: 1px solid #efefe8; background: transparent; color: #778478; font-size: 10px; font-weight: 600; text-align: left; cursor: pointer; }
.add-player-button span { width: 18px; height: 18px; display: grid; place-items: center; border: 1px dashed #b6c0b3; border-radius: 50%; font-size: 13px; font-weight: 400; }
.add-player-button:hover { color: var(--green); }
.activity-card { margin-top: 16px; padding-bottom: 13px; }
.activity-icon { color: #d1a26b; font-size: 16px; }
.activity-list { min-height: 120px; max-height: 180px; overflow-y: auto; margin: 0 -2px 10px; padding: 0 2px; }
.activity-item { display: flex; gap: 9px; padding: 9px 0; border-top: 1px solid #efefe8; }
.activity-item:first-child { border-top: 0; }
.activity-stamp { width: 25px; height: 25px; flex: 0 0 25px; display: grid; place-items: center; border-radius: 7px; background: #f1eee3; color: #b28a58; font-size: 10px; }
.activity-copy { min-width: 0; color: #7d8277; font-size: 10px; line-height: 1.55; }
.activity-copy strong { color: #48594b; font-weight: 600; }
.activity-copy .activity-points { color: #648262; font-weight: 700; }
.activity-empty { padding: 22px 4px; color: #a0a297; font-size: 10px; text-align: center; }
.chat-form { display: flex; gap: 5px; padding: 5px 5px 5px 10px; border: 1px solid #e9e9e1; border-radius: 7px; background: #fffefa; }
.chat-form:focus-within { border-color: #b5c8b3; }
.chat-form input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: #4a594d; font-size: 10px; }
.chat-form input::placeholder { color: #b1b2a7; }
.chat-form button { width: 26px; height: 26px; flex: 0 0 26px; border: 0; border-radius: 5px; background: #edf0e7; color: #58765b; font-size: 14px; cursor: pointer; }
.whatsapp-card { margin-top: 16px; padding: 8px 12px; }
.whatsapp-button { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; border: 1px solid #dfe8dc; border-radius: 7px; background: #edf5ec; color: #397b43; font-size: 11px; font-weight: 700; cursor: pointer; }
.whatsapp-button:hover { background: #e2efe1; border-color: #cadac6; }
.sidebar-footer { display: flex; align-items: center; gap: 7px; padding: 17px 4px; color: #a2a396; font-size: 10px; }
.sidebar-footer span { color: #c8a06a; }
.toast-message { position: fixed; z-index: 5; right: 25px; bottom: 24px; max-width: calc(100vw - 40px); padding: 12px 16px; border-radius: 8px; background: #203b2e; color: white; font-size: 12px; box-shadow: 0 8px 26px #1f382c2e; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s, transform .2s; }
.toast-message.visible { opacity: 1; transform: translateY(0); }
.toast-message.error { border: 1px solid #e8bbb5; background: #fff0ed; color: #ad3026; font-weight: 700; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@media (min-width: 1300px) {
  .game-shell { padding-right: 3.5%; padding-left: 3.5%; }
  .game-layout { grid-template-columns: minmax(0, 1fr) 292px; justify-content: stretch; gap: 36px; }
}
@media (max-width: 900px) {
  .game-shell { padding: 0 4%; }
  .game-layout { grid-template-columns: minmax(0, 1fr) 258px; gap: 20px; padding-top: 18px; }
  .board-frame { padding: 10px 10px 8px; }
  .board { gap: 2px; }
  .side-card { padding-right: 14px; padding-left: 14px; }
}
@media (max-width: 700px) {
  .game-shell { padding: 0 18px; }
  .game-layout { grid-template-columns: 1fr; gap: 18px; padding: 0 0 25px; }
  .play-column { display: flex; flex-direction: column; }
  .turn-panel { grid-column: 1 / -1; }
  .turn-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 10px; }
  .turn-status-row, .turn-panel .word-score-preview { grid-column: 1 / -1; }
  .turn-status-row > strong { font-size: 12px; }
  .turn-panel .word-score-preview { padding: 7px 0; }
  .turn-tools { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .turn-tools .play-button { grid-column: 1 / -1; }
  .sidebar { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-top: 0; }
  .activity-card { margin-top: 0; }
  .sidebar-footer { grid-column: 1 / -1; padding: 2px 4px; }
  .board { width: min(100%, 510px, max(220px, calc(100dvh - 160px))); }
  .board-frame { padding: 8px 8px 7px; }
}
@media (max-width: 500px) {
  .game-shell { padding: 0 13px; }
  .top-actions { gap: 7px; }
  h1 { margin-top: 10px; font-size: 25px; letter-spacing: -1.2px; }
  .quiet-button { margin-top: 13px; padding: 7px 8px; font-size: 9px; white-space: nowrap; }
  .mobile-break { display: initial; }
  .board { width: min(100%, max(220px, calc(100dvh - 160px))); gap: 1px; }
  .board-frame { padding: 6px 6px 6px; }
  .square { border-radius: 2px; }
  .board-coordinates { padding-top: 7px; font-size: 7px; }
  .rack { min-height: clamp(68px, 9vh, 84px); margin-top: 10px; }
  .rack { --rack-tile-size: clamp(28px, min(calc((100vw - 130px) / 8), calc((100dvh - 190px) / 8)), 46px); }
  .word-score-preview { font-size: 8px; }
  .word-score-preview strong { font-size: 15px; }
  .turn-tools .quiet-button, .turn-tools .play-button { padding: 9px 8px; font-size: 9px; }
  .sidebar { grid-template-columns: 1fr; }
  .activity-list { min-height: 72px; }
}
