:root {
  color-scheme: light;
  --page: #f8f7f2;
  --paper: #fffefa;
  --ink: #20382c;
  --muted: #5b695f;
  --line: #e4e5db;
  --green: #254f3d;
  --green-deep: #183a2d;
  --soft: #edf2e8;
  --gold: #e6ba66;
  --serif: Georgia, "Times New Roman", serif;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible + .switch {
  outline: 3px solid #b67822;
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.frame { width: min(1184px, calc(100% - 56px)); margin-inline: auto; }

.site-header { background: #fdfcf8; border-bottom: 1px solid var(--line); }
.header-inner { min-height: 65px; display: flex; justify-content: space-between; align-items: center; }
.brand { display: flex; gap: 5px; align-items: center; font: bold 1.42rem var(--serif); text-decoration: none; }
.brand-light { color: #437254; font-weight: normal; }
.brand-mark {
  display: grid; grid-template-columns: repeat(2, 7px); grid-template-rows: repeat(2, 7px);
  gap: 4px; place-content: center; width: 34px; height: 34px; border-radius: 9px;
  margin-right: 5px; background: var(--green);
}
.brand-mark i { background: #f2e3bf; border-radius: 1px; transform: rotate(45deg) scale(.82); }
.header-nav { display: flex; align-items: center; gap: 20px; }
.daily-link, .help-link {
  display: flex; align-items: center; min-height: 44px; gap: 8px; font-weight: 650; white-space: nowrap;
  font-size: .9rem; color: var(--green); text-decoration: none;
}
.daily-link:hover, .help-link:hover { text-decoration: underline; }
.daily-link[aria-current="page"] { text-decoration: underline; text-underline-offset: .22em; }
.help-link span { display: grid; place-items: center; border: 1px solid #8c9d88; border-radius: 50%; width: 19px; height: 19px; font-size: .76rem; }

.intro { padding: 32px 0 25px; }
.intro h1 { font: 500 clamp(2.3rem, 4.45vw, 3.8rem)/1.02 var(--serif); margin: 0 0 11px; letter-spacing: -.042em; }
.intro p { margin: 0; color: var(--muted); font-size: 1rem; line-height: 1.45; }

.game-grid { display: grid; grid-template-columns: minmax(0, 1fr) 288px; gap: 22px; align-items: start; }
.game { min-width: 0; }
.game, .side-card { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 5px 18px #273d2810; }
.game-top { display: flex; align-items: center; justify-content: space-between; min-height: 72px; gap: 8px; padding: 12px 17px; }
.game-name { display: flex; align-items: center; gap: 11px; min-width: 0; }
.game-name h2, .side-card h2 { margin: 0; font: bold 1.23rem/1.2 var(--serif); }
.game-name p { margin: 4px 0 0; color: var(--muted); font-size: .83rem; }
.board-emblem {
  flex: 0 0 37px; height: 37px; display: grid; place-items: center; border-radius: 9px;
  background: #eef1e6; color: #44694f; font-size: 1.45rem;
}
.game-stats { display: flex; align-items: center; text-align: center; gap: 14px; font-variant-numeric: tabular-nums; }
.game-stats p { display: grid; gap: 2px; margin: 0; min-width: 63px; }
.game-stats p + p { padding-left: 13px; border-left: 1px solid var(--line); }
.game-stats strong { font: bold 1.27rem/1 var(--serif); }
.game-stats span { font-size: .76rem; white-space: nowrap; color: var(--muted); }

.table {
  height: clamp(406px, 52vh, 500px); margin: 0 10px; border-radius: 11px; position: relative;
  overflow: hidden; isolation: isolate; border: 1px solid #17372b;
  background:
    radial-gradient(ellipse at 48% 40%, #366149 0%, #25503c 55%, #153c2f 100%);
  box-shadow: inset 0 0 30px #071e1a66;
}
.table::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(135deg, #b3c9a509 0 1px, transparent 1px 5px);
}
.table-border { position: absolute; inset: 9px; border: 1px solid #e2c07f54; border-radius: 6px; pointer-events: none; }
.corner { position: absolute; width: 17px; height: 17px; border: 1px solid #dbbd77a0; pointer-events: none; }
.corner-tl { top: 9px; left: 9px; border-radius: 6px 0 0; border-right: 0; border-bottom: 0; }
.corner-tr { top: 9px; right: 9px; border-radius: 0 6px 0 0; border-left: 0; border-bottom: 0; }
.corner-bl { bottom: 9px; left: 9px; border-radius: 0 0 0 6px; border-right: 0; border-top: 0; }
.corner-br { bottom: 9px; right: 9px; border-radius: 0 0 6px; border-left: 0; border-top: 0; }
.board-viewport { position: absolute; inset: 17px; display: grid; place-items: center; color: white; }
.board { position: relative; flex: none; isolation: isolate; }
.tile {
  position: absolute; appearance: none; display: block; padding: 1px; border: 1px solid #e1d6b2;
  border-radius: 10%; user-select: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  background: linear-gradient(155deg, #fffef5 5%, #f8efd7 94%);
  box-shadow: 1px 2px 0 #bb9970, 2px 3px 0 #846442, 2px 4px 3px #091c14ab;
  transition: filter .12s, background .12s, box-shadow .12s;
}
.tile[data-open="false"] { cursor: default; }
@media (hover: hover) { .tile[data-open="true"]:hover { filter: brightness(1.06); } }
.board.show-open .tile[data-open="false"] { filter: brightness(.79) saturate(.67); }
.tile.is-selected, .tile.is-hint {
  background: #ffedac; border-color: #9c6923;
  box-shadow: inset 0 0 0 2px #c9973c, 1px 2px 0 #c8954c, 2px 4px 3px #091c14ab;
}
.tile.is-hint { animation: glow .85s ease-in-out 3 alternate; }
.tile.is-blocked { box-shadow: inset 0 0 0 2px #bd4a37, 1px 2px 0 #a06a4e, 2px 4px 3px #091c14ab; }
.tile:focus-visible { outline: 2px solid #ffd975; outline-offset: -1px; }
@keyframes glow { to { filter: brightness(1.16); } }

.game-controls { display: flex; align-items: center; gap: 8px; padding: 13px 12px 12px; }
.control, .primary {
  display: inline-flex; justify-content: center; align-items: center; gap: 7px; min-height: 43px;
  border-radius: 9px; padding: 0 13px; border: 1px solid #dce2d6;
  color: var(--green-deep); background: #fffefb; font-size: .88rem; font-weight: 670; white-space: nowrap;
}
.control:hover:not(:disabled) { background: #eef3e9; }
.control:disabled { color: #6b766d; background: #f5f5ef; }
.control > span, .primary > span { font-size: 1.15em; }
.control-spacer { flex: 1; }
.primary { background: var(--green); color: #fffef7; border-color: var(--green); }
.primary:hover { background: var(--green-deep); }
.expand { width: 43px; padding: 0; }
.expand-icon {
  width: 15px; height: 15px; border: 1.5px solid currentColor;
  clip-path: polygon(0 0, 38% 0, 38% 10%, 62% 10%, 62% 0, 100% 0, 100% 38%, 90% 38%, 90% 62%, 100% 62%, 100% 100%, 62% 100%, 62% 90%, 38% 90%, 38% 100%, 0 100%, 0 62%, 10% 62%, 10% 38%, 0 38%);
}
.game-caption { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-inline: 12px; padding: 0 3px; border-top: 1px solid var(--line); min-height: 43px; }
.game-caption p { margin: 8px 0; color: var(--muted); font-size: .84rem; }
.text-button { color: var(--green); background: none; border: 0; min-height: 42px; padding: 0 3px; white-space: nowrap; font-size: .8rem; font-weight: 650; }
.text-button:hover { text-decoration: underline; }
.game-message {
  position: absolute; z-index: 1; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(310px, 87%);
  text-align: center; padding: 22px; border-radius: 14px; border: 1px solid #dfd4b9; background: #fffaf0;
  box-shadow: 0 8px 36px #09291dc0;
}
.game-message h3 { font: bold 1.6rem var(--serif); margin: 0 0 8px; }
.game-message p { color: var(--muted); font-size: .9rem; line-height: 1.5; margin: 0 0 13px; }
.game-message-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; }
.game-message-actions:has(#share-challenge:not([hidden])) .message-action {
  color: var(--green-deep); background: #fffefb; border-color: #dce2d6;
}
.game-message-actions:has(#share-challenge:not([hidden])) .message-action:hover { background: var(--soft); }

.sidebar { display: grid; min-width: 0; gap: 15px; }
.side-card { padding: 17px; min-width: 0; }
.side-card h2 { margin-bottom: 13px; }
.mode-list { display: grid; gap: 9px; }
.mode {
  border: 1px solid var(--line); border-radius: 10px; background: #fffefa; color: var(--ink);
  display: grid; grid-template-columns: 38px minmax(0, 1fr) 15px; align-items: center;
  gap: 9px; text-align: left; min-height: 60px; padding: 7px;
}
.mode:hover { border-color: #7b9883; }
.mode[aria-pressed="true"] { border-color: #789683; background: var(--soft); }
.mode strong, .mode small { display: block; }
.mode strong { font-size: .91rem; }
.mode small { color: var(--muted); font-size: .75rem; margin-top: 3px; line-height: 1.2; }
.mode-radio { width: 15px; height: 15px; border: 1px solid #8a9a8b; border-radius: 50%; align-self: center; }
.mode[aria-pressed="true"] .mode-radio { background: #34634a; border-color: #34634a; box-shadow: inset 0 0 0 3px var(--soft); }
.mode-art { display: grid; position: relative; width: 35px; height: 32px; place-self: center; }
.mode-art i { position: absolute; width: 10px; height: 12px; border: 1px solid #6b8d75; border-radius: 2px; background: #d9e7d8; left: 13px; top: 9px; }
.mode-art.turtle i:nth-child(1) { left: 2px; }
.mode-art.turtle i:nth-child(2) { left: 24px; }
.mode-art.turtle i:nth-child(3) { top: 1px; }
.mode-art.turtle i:nth-child(4) { top: 18px; }
.mode-art.turtle i:nth-child(5) { background: #a3beaa; }
.mode-art.big i { width: 13px; height: 17px; }
.mode-art.big i:nth-child(1) { left: 5px; top: 11px; }
.mode-art.big i:nth-child(2) { left: 10px; top: 7px; }
.mode-art.big i:nth-child(3) { left: 15px; top: 3px; background: #a3beaa; }
.daily-art {
  width: 25px; height: 24px; margin-top: 2px; color: #537962;
  border: 1px solid currentColor; border-top-width: 6px; border-radius: 4px; background: #e2ebdc;
}
.daily-art::before {
  content: ""; position: absolute; top: -9px; left: 5px; width: 2px; height: 6px;
  border-radius: 1px; background: currentColor; box-shadow: 10px 0 currentColor;
}
.daily-art::after {
  content: ""; position: absolute; top: 5px; left: 9px; width: 5px; height: 5px;
  border-radius: 1px; background: currentColor; transform: rotate(45deg);
}
.preference { position: relative; min-height: 43px; display: flex; align-items: center; gap: 9px; margin-top: 9px; cursor: pointer; font-size: .84rem; font-weight: 620; }
.preference input { position: absolute; width: 1px; height: 1px; padding: 0; opacity: 0; }
.switch { display: inline-block; position: relative; width: 32px; height: 18px; border-radius: 20px; background: #b9c5b9; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: white; transition: transform .15s; }
.preference input:checked + .switch { background: #34634a; }
.preference input:checked + .switch::after { transform: translateX(14px); }
.rules { scroll-margin-top: 20px; }
.rules p { font-size: .89rem; color: var(--muted); margin: 10px 0 0; line-height: 1.55; }
.pair-demo { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 10px; border-radius: 8px; background: #f2f3eb; }
.demo-tile { display: grid; place-items: center; width: 28px; height: 34px; border-radius: 4px; border: 1px solid #ded3b2; background: #fffbeb; color: #902f31; font: bold 1.13rem var(--serif); box-shadow: 1px 2px #c4a680; }
.demo-plus { color: #54705d; }
.footer { display: flex; justify-content: space-between; gap: 12px; padding: 22px 0; font-size: .81rem; color: var(--muted); }

dialog { border: 1px solid var(--line); border-radius: 14px; width: min(425px, calc(100% - 28px)); color: var(--ink); background: var(--paper); padding: 23px; }
dialog::backdrop { background: #15291eb0; }
dialog h2 { font: bold 1.6rem var(--serif); margin: 0 0 10px; }
dialog p { color: var(--muted); margin: 0 0 18px; line-height: 1.5; }
.dialog-controls { display: flex; justify-content: end; gap: 8px; }
.share-field { display: block; margin-bottom: 6px; color: var(--ink); font-size: .88rem; font-weight: 650; }
.share-url {
  display: block; width: 100%; min-height: 43px; padding: 8px 10px;
  border: 1px solid #a5b4a6; border-radius: 8px; color: var(--ink); background: #f7f8f2;
}
.share-url:focus-visible { outline: 3px solid #b67822; outline-offset: 2px; }
.share-status { min-height: 1.5em; margin: 6px 0 10px; font-size: .85rem; }
.share-controls { flex-wrap: wrap; }
.game.is-expanded { position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column; border-radius: 0; padding: max(0px, env(safe-area-inset-top)) max(0px, env(safe-area-inset-right)) max(0px, env(safe-area-inset-bottom)) max(0px, env(safe-area-inset-left)); }
.game.is-expanded .table { height: auto; min-height: 140px; flex: 1; }
body.game-expanded { overflow: hidden; }

@media (max-width: 960px) {
  .frame { width: calc(100% - 32px); }
  .game-grid { grid-template-columns: minmax(0, 1fr) 244px; gap: 13px; }
  .side-card { padding: 13px; }
}
@media (max-width: 760px) {
  .intro { padding: 22px 0 16px; }
  .intro h1 { margin-bottom: 6px; }
  .game-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .sidebar { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .table { height: clamp(390px, 56vh, 485px); }
}
@media (max-width: 520px) {
  .frame { width: calc(100% - 20px); }
  .header-inner { min-height: 52px; }
  .brand { font-size: 1.18rem; }
  .brand-mark { width: 28px; height: 28px; margin-right: 1px; }
  .header-nav { gap: 12px; }
  .daily-link, .help-link { font-size: .8rem; gap: 5px; }
  .intro { padding: 16px 0 12px; }
  .intro h1 { font-size: clamp(1.82rem, 7.5vw, 2.38rem); }
  .intro p { font-size: .9rem; }
  .game-top { min-height: 58px; padding: 8px; }
  .game-name { gap: 6px; }
  .game-name h2 { font-size: 1.08rem; }
  .game-name p { font-size: .75rem; }
  .board-emblem { flex-basis: 29px; height: 31px; font-size: 1.1rem; }
  .game-stats { gap: 5px; }
  .game-stats p { min-width: 49px; }
  .game-stats p + p { padding-left: 5px; }
  .game-stats strong { font-size: 1.08rem; }
  .game-stats span { font-size: .69rem; }
  .table { height: clamp(310px, 51svh, 430px); margin: 0 5px; }
  .table:has(.board[data-layout="classic"]) { height: clamp(236px, 64vw, 340px); }
  .game.is-expanded .table { height: auto; }
  .board-viewport { inset: 12px; }
  .table-border, .corner { display: none; }
  .game-controls { gap: 4px; padding: 8px 5px 7px; }
  .control, .primary { min-height: 43px; padding: 0 6px; font-size: .77rem; gap: 3px; }
  .control-spacer { min-width: 0; }
  .expand { width: 36px; }
  .game-caption { margin-inline: 6px; }
  .game-caption p { font-size: .76rem; }
  .text-button { font-size: .73rem; }
  .sidebar { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .side-card { padding: 13px; }
  .mode-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .mode { grid-template-columns: 22px minmax(0, 1fr) 12px; gap: 4px; padding: 4px; }
  .mode--daily { grid-column: 1 / -1; }
  .mode-art { transform: scale(.72); }
  .mode strong { font-size: .82rem; }
  .mode small { font-size: .7rem; }
  .mode-radio { width: 12px; height: 12px; }
}
@media (max-width: 385px) {
  .header-nav .help-link { display: none; }
}
@media (max-width: 355px) {
  .game-controls .control > span:not(.expand-icon), .new-game > span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
