:root {
  color-scheme: dark;
  --paper: #f4ebd5;
  --muted: #b6b09c;
  --gold: #e0b878;
  --line: #c5b18a32;
  --serif: "Playfair Display", Georgia, serif;
  --sans: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  min-width: 300px;
  isolation: isolate;
  min-height: 100svh;
  margin: 0;
  display: flex;
  flex-direction: column;
  color: var(--paper);
  font: 1rem var(--sans);
  background: radial-gradient(ellipse at 46% 48%, #222a1b 0%, #182119 48%, #0e1611 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: url("assets/linen.webp") repeat;
  opacity: .10;
  mix-blend-mode: soft-light;
}

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible { outline: 2px solid #f4c985; outline-offset: 4px; }
.symbols { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.emblem { color: var(--gold); }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 0 clamp(20px, 4.35vw, 67px);
  border-bottom: 1px solid #a59d7c26;
  background: #10181185;
}

.wordmark { display: flex; align-items: center; gap: 12px; color: #efe5cd; font: 500 1.125rem var(--serif); letter-spacing: .105em; white-space: nowrap; }
.wordmark i { color: #debc82; font-weight: 400; }
.wordmark .emblem { width: 30px; height: 30px; stroke-width: 1.2; }
.header-actions { display: flex; gap: 15px; align-items: center; }
.header-button, .sound-button { background: transparent; border: 1px solid transparent; color: #dedac8; min-height: 43px; display: inline-flex; justify-content: center; align-items: center; gap: 9px; border-radius: 8px; font-size: .875rem; font-weight: 600; transition: background .2s, border-color .2s; }
.header-button { padding: 0 10px; }
.sound-button { width: 43px; border-color: var(--line); }
.header-button:hover, .sound-button:hover { background: #e3cdaa16; border-color: var(--line); }
.sound-button[aria-pressed="false"] { color: var(--muted); }

.table { flex: 1; display: grid; justify-items: center; align-content: start; width: 100%; padding: clamp(33px, 4.2vh, 47px) 24px 24px; }
.title-block { text-align: center; }
.eyebrow { display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--gold); font-size: .75rem; font-weight: 700; line-height: 1.5; letter-spacing: .24em; }
.eyebrow span { width: 30px; height: 1px; opacity: .58; background: currentColor; }
h1 { margin: 9px 0 14px; font: 500 clamp(3.55rem, 7.15vw, 6.35rem)/1.04 var(--serif); letter-spacing: -.065em; }
h1 em { color: #e2bc80; font-weight: 400; }
.title-block p { margin: 0; color: #c9c2af; font-size: clamp(.93rem, 1.35vw, 1.11rem); line-height: 1.5; }
.game { width: min(100%, 1080px); }

.scoreboard {
  width: min(100%, 955px);
  margin: clamp(25px, 3.5vh, 38px) auto 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: clamp(12px, 3.7vw, 55px);
  position: relative;
  z-index: 2;
}

.player {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  align-items: center;
  gap: 13px;
  min-height: 64px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #111a13bd;
  transition: border-color .2s, background .2s;
}

.player.active { border-color: #e0b87875; background: linear-gradient(108deg, #b08b5125, #7f673211), #182019; }
.right-player { text-align: right; }
.player-avatar { display: grid; place-items: center; width: 39px; height: 39px; border: 1px solid var(--line); border-radius: 50%; color: #bab59e; }
.active .player-avatar { color: var(--gold); border-color: #d0a87358; background: #d0a87315; }
.player-info { display: grid; gap: 2px; }
.player-name { font-size: .96rem; font-weight: 700; line-height: 1.1; }
.player-caption { color: var(--muted); font-size: .77rem; white-space: nowrap; }
.score { min-width: 2.2ch; font: 500 2.15rem/.95 var(--serif); font-variant-numeric: lining-nums tabular-nums; color: #efe5c9; }
.active .score { color: #f3c783; }
.turn { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 135px; width: max-content; padding: 8px 13px; border: 1px solid #e0b87845; border-radius: 999px; background: #25291b; color: #efd39e; font-size: .83rem; font-weight: 700; text-align: center; }
.turn-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: #e9bf79; box-shadow: 0 0 10px #f2bc6a65; }

.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1536 / 570;
  margin: -1px auto -5px;
  isolation: isolate;
  touch-action: manipulation;
}

.board-photo {
  position: absolute;
  top: -38.6%;
  width: 100%;
  height: auto;
  max-width: none;
  user-select: none;
  pointer-events: none;
  filter: saturate(.86) brightness(.87);
  mask-image: linear-gradient(transparent 17%, #000 25%, #000 73%, transparent 86%), linear-gradient(90deg, transparent, #000 1.2%, #000 98.8%, transparent);
  mask-composite: intersect;
  z-index: -1;
}

.pits { position: absolute; inset: 0; }
.pit {
  position: absolute;
  display: block;
  left: var(--x);
  top: var(--y);
  width: 11.6%;
  aspect-ratio: 1;
  padding: 0;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 50%;
  background: transparent;
  isolation: isolate;
  transition: box-shadow .22s, background .22s;
}

.pit[aria-disabled="false"]:hover, .pit:focus-visible, .pit.suggested {
  background: #ffbd6723;
  box-shadow: inset 0 0 0 1px #ffdb9eb0, inset 0 0 24px #ffb35e28, 0 0 13px #ffb35e38;
}
.pit:focus-visible { outline-offset: -3px; }
.pit[aria-disabled="true"] { cursor: default; }
.pit.suggested { animation: hint-glow 1.1s ease-in-out 2; }
.pit.landing { background: #ffbc5422; }
.pit.harvest { box-shadow: inset 0 0 38px #ffd785b0; }
.pit-seeds { position: absolute; inset: 0; pointer-events: none; }
.seed { position: absolute; left: var(--sx); top: var(--sy); width: var(--size); height: auto; transform: translate(-50%, -50%) rotate(var(--angle)); filter: brightness(var(--brightness)) drop-shadow(1px 3px 2px #120a02c0); user-select: none; }
.flying-seed { position: absolute; z-index: 5; width: 2.7%; height: auto; pointer-events: none; filter: drop-shadow(0 7px 4px #0f0906b0); }
.seed.new-seed { animation: seed-drop .24s cubic-bezier(.19,.65,.4,1.4) both; }
.pit-count { position: absolute; bottom: 7%; left: 50%; transform: translateX(-50%); display: grid; place-items: center; min-width: 22px; height: 21px; padding: 0 3px; border: 1px solid #ffcd8f38; border-radius: 999px; background: #261408e0; color: #f3d8a4; font-size: clamp(.65rem, 1.04vw, .82rem); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }

@keyframes seed-drop {
  from { transform: translate(-50%, -115%) rotate(calc(var(--angle) - 27deg)) scale(1.3); opacity: .15; }
  to { transform: translate(-50%, -50%) rotate(var(--angle)) scale(1); opacity: 1; }
}
@keyframes hint-glow { 50% { box-shadow: inset 0 0 0 2px #ffe2ac, inset 0 0 30px #fdbf6c50, 0 0 16px #ffb35e75; } }

.game-message { position: relative; margin: 3px 0 21px; min-height: 1.5em; color: #d5cdb7; text-align: center; font-size: .94rem; line-height: 1.5; }
.toolbar { position: relative; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 14px; }
.mode-toggle, .game-actions { display: flex; gap: 7px; align-items: center; }
.mode-toggle { padding: 4px; gap: 3px; border: 1px solid var(--line); border-radius: 9px; background: #1017119e; }
.mode-button, .game-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); border-radius: 7px; min-height: 45px; padding: 0 15px; background: #11181282; color: #e8e0ca; font-size: .875rem; font-weight: 700; white-space: nowrap; transition: border-color .2s, color .2s, background .2s, opacity .2s; }
.mode-button { min-height: 35px; padding: 0 12px; border-color: transparent; background: transparent; color: #c2beaa; }
.mode-button .icon, .game-button .icon { width: 16px; height: 16px; }
.mode-button[aria-pressed="true"] { color: #f2d4a3; border-color: #ccae792e; background: #a8915f2b; }
.game-button:not(:disabled):hover, .mode-button:hover { border-color: #e0b87891; background: #d0ad6628; }
.game-button:disabled { opacity: .42; }
.game-button.primary { border-color: #efcb95; background: linear-gradient(#e5bf84,#d4aa6f); color: #20180d; box-shadow: inset 0 1px #fbe6bfd1; }
.game-button.primary:hover { background: #f0ce96; }

.site-footer { min-height: 55px; margin: 0 clamp(20px, 4.35vw, 67px); border-top: 1px solid #a59d7c2b; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; color: #a49f8c; font-size: .72rem; letter-spacing: .15em; font-weight: 700; gap: 12px; }
.site-footer span:last-child { justify-self: end; }
.site-footer b { color: var(--gold); padding: 0 3px; }
.site-footer .emblem { opacity: .68; }

.modal { width: min(550px, calc(100% - 32px)); max-height: calc(100% - 32px); padding: clamp(24px, 5vw, 41px); border: 1px solid #a88a57a3; border-radius: 13px; color: var(--paper); background: #1a2319; box-shadow: 0 18px 80px #000a; }
.modal::backdrop { background: #080b08bc; backdrop-filter: blur(5px); }
.modal .eyebrow { justify-content: start; margin-bottom: 8px; }
.modal h2 { margin: 0 25px 13px 0; font: 500 clamp(2rem, 5vw, 2.7rem)/1.14 var(--serif); letter-spacing: -.045em; }
.modal p, .rules-list { color: #d8d0bd; line-height: 1.55; }
.close-modal { position: absolute; top: 13px; right: 13px; display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 7px; background: transparent; }
.close-modal:hover { background: #d0ad6628; }
.rules-list { padding-left: 21px; }
.rules-list li { padding-left: 6px; margin: 0 0 12px; }
.rules-list li::marker { color: var(--gold); font-weight: 700; }
.rules-list strong { color: var(--paper); }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; margin-top: 22px; }

@media (max-width: 700px) {
  .site-header { min-height: 64px; }
  .table { padding-top: 37px; padding-inline: 13px; }
  .scoreboard { gap: 8px; margin-top: 30px; }
  .player { gap: 7px; min-height: 59px; padding: 7px 8px; }
  .player-avatar { display: none; }
  .player:not(.right-player) { grid-template-columns: minmax(0, 1fr) auto; }
  .right-player { grid-template-columns: auto minmax(0, 1fr); }
  .player-name { font-size: .86rem; }
  .player-caption { font-size: .68rem; }
  .score { font-size: 1.65rem; }
  .turn { min-width: 0; max-width: 112px; padding: 7px 8px; gap: 5px; font-size: .72rem; }
  .game-message { margin-top: 12px; }
}
@media (max-width: 460px) {
  .site-header { padding-inline: 13px; }
  .header-actions { gap: 4px; }
  .header-button { padding: 0 6px; }
  .wordmark { gap: 6px; font-size: .95rem; letter-spacing: .045em; }
  .wordmark .emblem { width: 22px; height: 22px; }
  .sound-button { width: 38px; min-height: 38px; }
  .scoreboard { grid-template-columns: minmax(0,1fr) minmax(0,1fr); row-gap: 9px; column-gap: 12px; }
  .turn { grid-row: 2; grid-column: 1 / -1; justify-self: center; max-width: none; }
  .player { padding-inline: 11px; }
  .player-caption { font-size: .75rem; }
  .board { margin-block: 6px 0; }
  .pit-count { min-width: 15px; height: 14px; bottom: 4%; }
  .toolbar { gap: 9px; }
  .mode-button, .game-button { padding-inline: 11px; }
  .site-footer { margin-inline: 13px; font-size: .61rem; letter-spacing: .075em; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

[hidden] { display: none !important; }
.room-bar { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 8px 16px; margin: -13px 0 16px; color: var(--muted); font-size: .875rem; }
.room-invite { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: #11181282; color: var(--gold); font-size: .875rem; font-weight: 700; }
.room-invite:hover { background: #d0ad6628; border-color: #e0b87891; }
.room-invite .icon { width: 16px; height: 16px; }
.invite-label { display: block; margin-bottom: 6px; color: var(--paper); font-weight: 600; font-size: .875rem; }
.invite-input { width: 100%; min-height: 45px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 7px; background: #111812; color: var(--paper); font: inherit; }
.invite-input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.modal .room-feedback { margin-bottom: 0; color: var(--gold); }
.mode-button:disabled { cursor: default; }
