:root {
  color-scheme: dark;
  --table: #1f2420;
  --paper: #fbf1dc;
  --paper-2: #f3e2c2;
  --ink: #3b2718;
  --muted: #8a6c52;
  --water: #3d8fd6;
  --clay: #d0623a;
  --shadow: 0 3px 0 rgba(58, 32, 14, 0.28), 0 10px 24px rgba(0, 0, 0, 0.3);
  --sans: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--table);
  color: var(--paper);
  font-family: var(--sans);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

canvas#game { position: fixed; inset: 0; display: block; }

button { font: inherit; color: inherit; cursor: pointer; }

/* the top bar: little paper labels pinned to the table */
.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 58px;
  padding: max(8px, env(safe-area-inset-top)) 8px 0;
  display: flex;
  align-items: center;
  gap: 5px;
  z-index: 5;
}
.hud[hidden] { display: none; }
.hud p { margin: 0; }
.hud-season {
  flex: 1;
  min-width: 0;
  padding: 6px 8px 7px;
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.hud-season p { display: flex; justify-content: space-between; gap: 4px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.hud-season p span { flex: none; }
.hud-season p small { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 11px; font-weight: 600; color: var(--muted); }
.bar { height: 5px; margin-top: 4px; border-radius: 3px; background: var(--paper-2); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--water); }
.stat {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  padding: 8px 5px;
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.stat b { font-variant-numeric: tabular-nums; }
.icon {
  flex: none;
  width: 34px;
  height: 38px;
  border-radius: 10px;
  border: 0;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 16px;
  font-weight: 800;
}
.icon:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(58, 32, 14, 0.28); }

.hint-line {
  position: fixed;
  left: 50%;
  bottom: max(8px, env(safe-area-inset-bottom));
  transform: translateX(-50%) rotate(-0.6deg);
  width: max-content;
  max-width: calc(100vw - 24px);
  margin: 0;
  padding: 7px 12px;
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
  text-align: center;
  font-size: 14px;
  line-height: 1.35;
  pointer-events: none;
  z-index: 5;
}
.hint-line:empty { display: none; }

#ui { position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 10; }
.panel {
  pointer-events: auto;
  width: min(340px, calc(100vw - 32px));
  padding: 26px 22px 22px;
  border-radius: 18px;
  background: var(--paper);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 5px 0 rgba(58, 32, 14, 0.3), 0 22px 50px rgba(0, 0, 0, 0.45);
  transform: rotate(-0.8deg);
}
.panel h1 { margin: 0 0 8px; font-size: 46px; letter-spacing: 0.02em; color: var(--clay); }
.panel h2 { margin: 0 0 8px; font-size: 28px; }
.panel p { margin: 6px 0; line-height: 1.4; }
.panel .big { font-size: 19px; font-weight: 700; }
.panel .muted { color: var(--muted); font-size: 14px; }
.btn {
  margin-top: 14px;
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: 14px;
  background: var(--clay);
  color: #fff8ec;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 4px 0 #9c4325;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #9c4325; }

.choices { display: grid; gap: 8px; margin-top: 12px; }
.choice {
  display: grid;
  grid-template-columns: 34px 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  text-align: left;
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  background: var(--paper-2);
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(58, 32, 14, 0.25);
}
.choice:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(58, 32, 14, 0.25); }
.choice-icon { grid-row: span 2; display: grid; place-items: center; }
.choice b { font-size: 16px; }
.choice small { color: var(--muted); font-size: 13px; }
.rewards .big { font-size: 15px; }

.btn small { display: block; font-size: 12px; font-weight: 600; opacity: 0.85; margin-top: 2px; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--paper-2); margin-top: 8px; }
.choice.picked { box-shadow: inset 0 0 0 2px var(--clay), 0 3px 0 rgba(58, 32, 14, 0.25); }
.panel .choices { margin-top: 14px; }

.stat.empty { animation: empty 0.9s ease-in-out infinite; }
@keyframes empty { 50% { background: #f6c3b4; color: #8f1f12; } }
.hud-season p small.low { color: #c0392b; font-weight: 800; animation: lowwater 1.1s ease-in-out infinite; }
@keyframes lowwater { 50% { color: #ff6a4d; } }

.update {
  position: fixed;
  top: calc(64px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  max-width: calc(100vw - 24px);
  padding: 9px 14px;
  border: 0;
  border-radius: 12px;
  background: var(--water);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow);
}
.langs { display: flex; justify-content: center; gap: 6px; margin: 14px 0 0; }
.langs button { border: 0; background: transparent; color: var(--muted); font-weight: 700; padding: 4px 8px; border-radius: 8px; }
.langs button.on { background: var(--paper-2); color: var(--ink); }

.panel.help { width: min(400px, calc(100vw - 24px)); max-height: calc(100vh - 40px); overflow-y: auto; text-align: left; }
.panel.help h2 { text-align: center; }
.legend { display: grid; gap: 8px; margin-top: 8px; }
.legend-row { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: center; font-size: 14px; line-height: 1.35; }
.legend-pic { display: grid; place-items: center; }
.panel .logo-sub { margin: -10px 0 10px; font-weight: 800; letter-spacing: 0.04em; color: var(--water); }
