:root { --ink: #23262b; --muted: #6f7680; --felt: #1f5a43; --felt2: #174634; --card: #fffdf7; --p0: #2f6fd0; --p1: #d0563f;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--felt2); color: var(--ink); font: 15px/1.45 var(--ui); }

#game { --fa: #24694e; --fb: #1f5a43; --fc: #174634; position: relative; display: flex; flex-direction: column; height: 100vh; height: 100svh; min-height: 480px; overflow: hidden;
  background: radial-gradient(ellipse 90% 80% at 50% 45%, var(--fa) 0%, var(--fb) 55%, var(--fc) 100%); -webkit-user-select: none; user-select: none; }
#game[data-theme=num], #game[data-theme=classic] { --fa: #24694e; --fb: #1f5a43; --fc: #174634; }
#game[data-theme=blue] { --fa: #2b5f8f; --fb: #224d75; --fc: #183856; }
#game[data-theme=walnut] { background: repeating-linear-gradient(92deg, rgba(0,0,0,0.05) 0 3px, transparent 3px 11px),
  linear-gradient(180deg, #7a4f2e, #5e3a20 60%, #4a2d18); }
#game[data-theme=walnut]::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse 80% 70% at 50% 45%, rgba(255,220,170,0.12), transparent 70%); }
header { flex: none; height: 52px; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 16px; color: #f4efe2;
  background: rgba(10,30,22,0.45); border-bottom: 1px solid rgba(255,255,255,0.08); }
h1 { font-size: 17px; margin: 0 4px 0 0; font-weight: 800; white-space: nowrap; }
.grow { flex: 1; }
button, select { font: 600 14px var(--ui); border: 1px solid rgba(0,0,0,0.2); background: var(--card); color: var(--ink); border-radius: 10px; padding: 7px 12px; cursor: pointer; }
header button { background: rgba(255,255,255,0.1); color: #f4efe2; border-color: rgba(255,255,255,0.22); }
header button[aria-pressed=true] { background: rgba(255,255,255,0.24); }
.short { display: none; }
.lvl { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; font-size: 13px; }
.lvl i { width: 8px; height: 8px; border-radius: 50%; background: #e0a24c; }
.lvl span { opacity: 0.6; font-size: 10px; }
.lvl[data-l=easy] i { background: #6cc070; } .lvl[data-l=hard] i { background: #e5573f; } .lvl[data-l=p2] i { background: #7fb2e5; }
.lvl[data-l=daily] i { background: #f2c94c; box-shadow: 0 0 0 3px rgba(242,201,76,0.3); }

#scores { flex: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 8px; padding: 8px 8px 0; }
.pl { display: flex; align-items: center; gap: 8px; padding: 4px 14px; border-radius: 999px; background: rgba(255,253,247,0.94); box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  border: 2px solid transparent; transition: border-color 0.2s; font-weight: 600; white-space: nowrap; }
.pl b { display: inline-block; font-size: 19px; min-width: 22px; text-align: right; }
.pl { padding: 3px 12px 3px 10px; }
.pl i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.pl u { text-decoration: none; font-size: 11px; font-weight: 600; color: var(--muted); }
.pl.on { border-color: #1f5a43; background: #fff; box-shadow: 0 0 0 3px rgba(255,213,74,0.55), 0 2px 10px rgba(0,0,0,0.2); }
.pl.open::after { content: 'OPEN'; font-size: 9px; font-weight: 800; background: #e8a33a; color: #2b1d05; border-radius: 6px; padding: 1px 5px; }
.pl.bump b { animation: bump 0.4s ease-out; }
@keyframes bump { 40% { transform: scale(1.4); } }
#rulesTag { flex-basis: 100%; order: 9; color: rgba(244,239,226,0.75); font-size: 12px; text-align: center; line-height: 1.25; margin-top: -2px; }

#table { position: relative; flex: 1; min-height: 0; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#tracker { position: absolute; top: 8px; right: 8px; bottom: 8px; width: 230px; overflow-y: auto; padding: 10px 12px; border-radius: 14px;
  background: #fffdf7; box-shadow: 0 8px 24px rgba(0,0,0,0.3); display: none; }
#game.trk #tracker { display: block; }
#tracker .th { font-weight: 800; display: flex; justify-content: space-between; align-items: center; }
#tracker .th button { padding: 2px 8px; font-size: 12px; }
.tsub { font-size: 12px; color: var(--muted); margin: 2px 0 8px; }
.void { color: #c4402f; }
.tr { display: grid; grid-template-columns: 28px 1fr; gap: 6px; align-items: start; padding: 5px 0; border-top: 1px solid rgba(0,0,0,0.07); }
.tr .pip { width: 26px; height: 26px; border-radius: 6px; background: #f6f0e0; border: 1px solid rgba(0,0,0,0.2); display: flex; align-items: center; justify-content: center; font-weight: 800; }
.tr .cnt { font-size: 12px; color: var(--muted); }
.tr .cnt b { color: var(--ink); }
.tr .cnt .void { font-weight: 700; margin-left: 4px; }
.tr .chips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 2px; }
.chip { font-size: 11px; font-weight: 700; padding: 0 5px; border-radius: 4px; background: #efe7d2; border: 1px solid rgba(0,0,0,0.12); }
.tr.none .pip { opacity: 0.4; }

/* table style popover */
#themes { position: absolute; z-index: 8; top: 58px; right: 12px; width: 300px; max-width: calc(100vw - 24px); padding: 12px; border-radius: 16px;
  background: var(--card); color: var(--ink); box-shadow: 0 16px 40px rgba(0,0,0,0.35); opacity: 0; transform: translateY(-6px); pointer-events: none; transition: opacity 0.18s, transform 0.18s; }
#themes.show { opacity: 1; transform: none; pointer-events: auto; }
#themes .ph { font-weight: 800; font-size: 15px; margin: 2px 4px 10px; }
#themes .grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
#themes .sw { display: flex; flex-direction: column; gap: 6px; padding: 6px; border-radius: 12px; background: #fff; border: 2px solid transparent; text-align: left; font-size: 12.5px; font-weight: 700; color: var(--ink); }
#themes .sw[aria-pressed=true] { border-color: #2f8f5a; }
#themes .pv { display: block; border-radius: 8px; overflow: hidden; background: radial-gradient(ellipse at 50% 45%, var(--fa), var(--fc)); }
#themes .pv[data-theme=walnut] { background: linear-gradient(180deg, #7a4f2e, #4a2d18); }
#themes .pv canvas { display: block; width: 100%; height: auto; }
.pv[data-theme=color], .pv[data-theme=num], .pv[data-theme=classic] { --fa: #24694e; --fc: #174634; } .pv[data-theme=blue] { --fa: #2b5f8f; --fc: #183856; } 
/* coach */
#coach { position: absolute; z-index: 4; left: 50%; top: 56px; transform: translate(-50%, -8px); width: max-content; max-width: min(540px, calc(100% - 24px));
  padding: 10px 16px; border-radius: 14px; background: var(--card); color: var(--ink); box-shadow: 0 8px 26px rgba(0,0,0,0.3);
  font-size: 14px; line-height: 1.4; opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; border-left: 4px solid #3f8f5a; cursor: pointer; }
#coach.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#coach.warn { border-left-color: #d9a441; }
#coach b { display: block; font-size: 13px; margin-bottom: 2px; }
#overCoach { font-size: 14px; line-height: 1.45; margin: 0 0 14px; padding: 10px 12px; border-radius: 12px; background: rgba(63,143,90,0.08); border-left: 3px solid #3f8f5a; }
#overCoach:empty { display: none; }
#overCoach b { display: block; font-size: 13px; margin-bottom: 2px; }
.note { font-size: 13px; color: var(--muted); margin: -4px 0 12px; }
.note[hidden], .row[hidden], .chk[hidden] { display: none; }
.chk { display: flex; align-items: center; gap: 8px; margin: 4px 0 14px; }
#curtain { background: rgba(10,20,15,0.82); }
#curtain p { color: var(--muted); margin: 0 0 14px; }

#bar { flex: none; display: flex; justify-content: center; padding: 6px 8px max(10px, env(safe-area-inset-bottom)); }
#status { padding: 7px 18px; border-radius: 999px; background: rgba(255,253,247,0.94); box-shadow: 0 4px 16px rgba(0,0,0,0.2); font-size: 14px; max-width: 100%; text-align: center; }

.dlg { position: absolute; inset: 0; z-index: 10; display: none; align-items: center; justify-content: center; background: rgba(10,20,15,0.45); }
.dlg.show { display: flex; }
.dlg .card { width: min(380px, calc(100vw - 32px)); background: var(--card); color: var(--ink); border-radius: 18px; padding: 20px 22px; box-shadow: 0 20px 50px rgba(0,0,0,0.35); }
.dh { font-size: 20px; font-weight: 800; margin-bottom: 12px; }
.row { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.row select { width: 100%; }
.btns { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
button.go { background: linear-gradient(#3f8a63, #2c6e4c); color: #fff; border-color: #245a3e; }
#over { align-items: flex-end; padding-bottom: max(12px, env(safe-area-inset-bottom)); background: rgba(10,20,15,0.25); }
#overBig { font-size: 44px; font-weight: 800; text-align: center; margin: 4px 0; }
#overSub { text-align: center; color: var(--muted); margin: 0 0 14px; }

#trackStrip { display: none; }
/* below the game */
#more { display: flex; align-items: center; justify-content: center; height: 44px; color: rgba(244,239,226,0.7); text-decoration: none; font-size: 14px; border-top: 1px solid rgba(255,255,255,0.08); }
article { padding: 8px 16px 48px; color: #d9e4dc; }
article > div { max-width: 720px; margin: 0 auto; }
article h2 { font-size: 22px; margin: 32px 0 10px; color: #f4efe2; }
article h3 { font-size: 17px; margin: 22px 0 6px; color: #f4efe2; }
article p, article li { font-size: 16px; line-height: 1.6; color: #cfdcd3; }
article strong { color: #f4efe2; }
article a { color: #ffd88a; }
.boxes { width: 100%; border-collapse: collapse; margin: 8px 0 12px; font-size: 15px; }
.boxes th, .boxes td { text-align: left; padding: 7px 10px; border-bottom: 1px solid rgba(255,255,255,0.12); color: #cfdcd3; vertical-align: top; }
.boxes th { color: #f4efe2; font-size: 13px; text-transform: uppercase; letter-spacing: 0.4px; }
button.print { background: rgba(255,255,255,0.1); color: #f4efe2; border-color: rgba(255,255,255,0.25); }
footer { text-align: center; color: rgba(244,239,226,0.6); font-size: 13px; padding: 24px 16px 40px; }
footer a { color: #ffd88a; }
#printSheet { display: none; }
@media print {
  html, body { background: #fff; color: #000; }
  body > *:not(#printSheet) { display: none !important; }
  #printSheet { display: block; font: 12pt/1.4 Georgia, serif; color: #000; }
  #printSheet h2 { font-size: 22pt; margin: 0 0 8pt; }
  #printSheet h3 { font-size: 14pt; margin: 12pt 0 4pt; }
  #printSheet ol { padding-left: 18pt; }
  #printSheet .src { font-size: 9.5pt; color: #444; }
}

@media (max-width: 899px) {
  #game.trk #tracker { display: none; }
  #game.trk.trkOpen #tracker { display: block; top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 70%; z-index: 5; }
  #game.trk #trackStrip { display: flex; flex: none; flex-wrap: wrap; justify-content: center; max-width: calc(100% - 16px); align-self: center; gap: 2px 1px; margin: 4px 8px 0; padding: 4px 6px; border-radius: 12px;
    background: rgba(255,253,247,0.92); border: 0; box-shadow: 0 2px 10px rgba(0,0,0,0.2); font-size: 12px; }
  #trackStrip .tc { display: flex; align-items: center; gap: 2px; padding: 1px 3px 1px 1px; border-radius: 7px; color: var(--muted); font-weight: 600; font-size: 11px; }
  #trackStrip .tc b { min-width: 17px; height: 17px; border-radius: 5px; background: #f6f0e0; border: 1px solid rgba(0,0,0,0.2); color: var(--ink);
    display: inline-flex; align-items: center; justify-content: center; font-size: 11px; }
  #trackStrip .tc.v { background: rgba(196,64,47,0.12); color: #c4402f; }
  #trackStrip .tc.z { opacity: 0.4; }
}
@media (max-width: 560px) {
  h1 { font-size: 15px; } .long { display: none; } .short { display: inline; }
  .pl { padding: 3px 10px; font-size: 13px; } .pl b { font-size: 17px; }
  #rulesTag { font-size: 11px; }
  #status { font-size: 13px; padding: 6px 14px; }
}
@media (max-width: 440px) {
  header { gap: 4px; padding: 0 6px 0 10px; } h1 { font-size: 13px; margin-right: 0; } header button { padding: 7px 8px; }
}
@media (max-width: 400px) {
  header { gap: 6px; padding: 0 8px 0 12px; } h1 { font-size: 14px; }
  .lvl { display: none; } header button { padding: 7px 8px; }
}

.sc { margin: 0 0 8px; font-size: 15px; }
.sc th, .sc td { color: var(--ink); border-bottom: 1px solid rgba(0,0,0,0.1); padding: 6px 8px; }
.sc th { color: var(--muted); font-size: 12px; }
.sc td:nth-child(n+2), .sc th:nth-child(n+2) { text-align: right; }
.sc i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; }
.sc tr.win td { font-weight: 800; background: rgba(63,143,90,0.1); }
#overBig { font-size: 16px; font-weight: 600; text-align: left; margin: 0; }
#hintBtn:disabled { opacity: 0.45; cursor: default; }
.pt { width: 100%; border-collapse: collapse; margin-top: 8pt; }
.pt th, .pt td { border: 1px solid #444; padding: 5pt 6pt; height: 17pt; font-size: 10pt; text-align: left; color: #000; }
