:root {
  --bg1: #22524a;
  --bg2: #12302b;
  --ivory: #fbf6e9;
  --ink: #1b1f2a;
  --gold: #f2c94c;
  --accent: #2f6f5e;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 90% at 50% 30%, var(--bg1), var(--bg2));
  color: var(--ivory);
  font: 18px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
header { padding: 10px 12px 4px; display: flex; flex-direction: column; gap: 8px; max-width: 720px; width: 100%; margin: 0 auto; }
.brand { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.logo { font: 600 23px/1 Georgia, "Times New Roman", serif; letter-spacing: .02em; }
#dayline { font-size: 16px; opacity: .88; text-align: right; }
.bar { display: grid; grid-template-columns: 1fr 1fr 1fr 52px; gap: 8px; }
button {
  font: inherit; font-weight: 600; min-height: 48px; padding: 0 10px;
  border-radius: 12px; border: 0; background: #f6efdf; color: var(--ink);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .3); cursor: pointer; touch-action: manipulation;
}
button:active { transform: translateY(1px); box-shadow: none; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, .t:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.status { font-size: 16px; opacity: .92; text-align: center; }
#lostNote { background: rgba(0, 0, 0, .28); border-radius: 12px; padding: 8px 10px; font-size: 16px; text-align: center; }
#lostNote button { min-height: 48px; margin: 6px 4px 0; font-size: 16px; }
main { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
#board { position: relative; touch-action: manipulation; }

/* Tiles: ivory face, a thin ivory side and a green back, like a real tile. */
.t {
  position: absolute;
  border-radius: calc(var(--w) * .11);
  background: linear-gradient(150deg, #fffdf7 0%, #f7f0de 55%, #ebdec1 100%);
  box-shadow:
    inset 0 0 0 1px rgba(110, 90, 50, .35),
    inset 1px -1px 1px rgba(255, 255, 255, .9),
    calc(var(--d) * -.45) calc(var(--d) * .45) 0 #d9c79f,
    calc(var(--d) * -1) var(--d) 0 #2c6a59,
    calc(var(--d) * -1.1) calc(var(--d) * 1.25) calc(var(--d) * 1.4) rgba(0, 0, 0, .42);
  cursor: pointer;
  transition: opacity .2s ease, transform .2s ease, visibility 0s;
}
.t svg { position: absolute; left: 5%; top: 4%; width: 90%; height: 92%; pointer-events: none; }
.t.blocked::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: rgba(40, 45, 40, .15); pointer-events: none; }
.t.sel { background: linear-gradient(150deg, #fff8d8, #f5e19c); transform: translate(1px, -3px); }
.t.sel::before { content: ""; position: absolute; inset: -3px; border-radius: inherit; border: 3px solid var(--gold); pointer-events: none; }
.t.hint::before { content: ""; position: absolute; inset: -4px; border-radius: inherit; border: 3px solid #86e3c6; animation: pulse 1.1s ease-in-out infinite; pointer-events: none; }
.t.gone { opacity: 0; transform: scale(.92); visibility: hidden; transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s; }
.t.no { animation: shake .3s; }
@keyframes pulse { 50% { opacity: .3; } }
@keyframes shake { 25% { translate: -3px 0; } 75% { translate: 3px 0; } }

#toast {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  width: max-content; max-width: min(92vw, 520px);
  background: rgba(12, 24, 21, .94); color: var(--ivory);
  padding: 12px 16px; border-radius: 12px; font-size: 17px; text-align: center;
  opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 5000;
}
#toast.on { opacity: 1; }
#card { position: fixed; inset: 0; background: rgba(8, 20, 17, .62); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 6000; }
#card[hidden] { display: none; }
.panel { background: var(--ivory); color: var(--ink); border-radius: 18px; padding: 22px 20px; max-width: 440px; width: 100%; box-shadow: 0 10px 40px rgba(0, 0, 0, .45); }
.panel h2 { margin: 0 0 10px; font: 600 24px/1.2 Georgia, "Times New Roman", serif; }
.panel p, .panel li { font-size: 18px; margin: 8px 0; }
.panel ul, .panel ol { padding-left: 22px; margin: 8px 0; }
.panel .row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.panel .row button { flex: 1; min-width: 130px; background: #e8dfcb; }
.panel .row button.primary { background: var(--accent); color: #fff; }
.panel label { display: flex; gap: 10px; align-items: center; font-size: 17px; margin-top: 12px; }
.panel input[type="checkbox"] { width: 24px; height: 24px; flex: none; }
.small { font-size: 16px !important; opacity: .8; }
.panel { max-height: calc(100dvh - 32px); overflow-y: auto; }
.sharepic { display: block; width: 46%; max-width: 220px; margin: 12px auto 4px; }
.sharepic img { display: block; width: 100%; height: auto; border-radius: 12px; box-shadow: 0 4px 14px rgba(0, 0, 0, .3); }
.days { display: grid; gap: 8px; margin-top: 10px; }
.days button { width: 100%; text-align: left; background: #efe7d4; }

/* Warm evening colours after dark (G022): a darker, warmer table and softer tiles. */
html.evening { --bg1: #4b3a24; --bg2: #21170c; }
html.evening .t:not(.sel) { background: linear-gradient(150deg, #fdf6e6 0%, #f4e9cf 55%, #e8d6b2 100%); }
/* Large Print (G020): plainer, lighter faces behind the big numbers. Comes after evening so it wins. */
html.lp .t:not(.sel) { background: linear-gradient(150deg, #fffef9 0%, #f8f1e1 100%); }
@media (prefers-reduced-motion: reduce) {
  .t, .t.gone { transition: none; }
  .t.hint::before, .t.no { animation: none; }
}
.panel a { color: var(--accent); font-weight: 600; }
