:root {
  --page: #efe6d6;
  --page-deep: #e4d7c1;
  --ink: #23302b;
  --ink-soft: #5a6a62;
  --felt: #1d5c44;
  --felt-deep: #14432f;
  --rail: #5c3a22;
  --rail-light: #8a5a33;
  --brass: #c9a227;
  --card: #fbf6ea;
  --line: rgba(35, 48, 43, 0.14);
  --shadow: 0 18px 40px -24px rgba(24, 34, 28, 0.55);
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -10%, #f7efe1 0%, rgba(247, 239, 225, 0) 60%),
    linear-gradient(180deg, var(--page) 0%, var(--page-deep) 100%);
  min-height: 100%;
  display: flex;
  justify-content: center;
  padding: 28px 20px 40px;
}

.app {
  width: min(100%, 1040px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- header ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 30%, #fff8e6 0 18%, #e9dfc6 19% 52%, #c9a227 53% 74%, #8a6c14 75% 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55), 0 6px 14px -8px rgba(0, 0, 0, 0.6);
}

.brand-text h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.01em;
  font-weight: 600;
}

.tagline {
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--ink-soft);
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary-btn {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #fdf8ec;
  background: linear-gradient(180deg, #2c6e51, #1b5340);
  border: 1px solid #14402f;
  border-radius: 999px;
  padding: 10px 20px;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.22) inset, 0 10px 18px -12px rgba(16, 40, 30, 0.9);
  transition: transform 120ms ease, filter 160ms ease;
}

.primary-btn:hover { filter: brightness(1.07); }
.primary-btn:active { transform: translateY(1px); }

.icon-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  transition: background 160ms ease;
}

.icon-btn:hover { background: #fffdf6; }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn .icon-off { display: none; }
.icon-btn[aria-pressed="false"] .icon-on { display: none; }
.icon-btn[aria-pressed="false"] .icon-off { display: block; }

/* ---------- stats ---------- */

.hud {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.stat {
  flex: 1 1 120px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.stat-value {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.stat-time .stat-value { color: #7a5f12; }

/* ---------- advertisement ---------- */

.ad-slot {
  margin: 0 auto;
  width: 100%;
  max-width: 760px;
  padding: 10px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(251, 246, 234, 0.7);
  text-align: center;
}

.ad-kicker {
  display: block;
  margin-bottom: 6px;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.ad-top-inner {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-top-inner ins {
  width: 100%;
}

/* ---------- table ---------- */

.table-wrap {
  position: relative;
  border-radius: var(--radius);
  background: var(--rail);
  padding: 0;
  box-shadow: 0 30px 60px -34px rgba(20, 28, 22, 0.85), 0 2px 0 rgba(255, 255, 255, 0.12) inset;
}

#table {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;
  border-radius: var(--radius);
  cursor: crosshair;
  touch-action: none;
}

#table:focus-visible {
  outline: 3px solid var(--brass);
  outline-offset: 3px;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  border-radius: var(--radius);
  background: rgba(16, 34, 26, 0.62);
  backdrop-filter: blur(3px);
  animation: veil 240ms ease;
}

.overlay[hidden] { display: none; }

.overlay-card {
  width: min(100%, 420px);
  background: var(--card);
  border-radius: 18px;
  padding: 26px 28px 24px;
  text-align: center;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.7);
  animation: rise 300ms cubic-bezier(.2, .8, .3, 1);
}

.overlay-kicker {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #7a5f12;
}

.overlay-card h2 {
  margin: 0 0 8px;
  font-size: 30px;
  font-weight: 600;
}

.overlay-body {
  margin: 0 0 20px;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.5;
}

@keyframes veil { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ---------- footer ---------- */

.hint {
  margin: 0;
  font-size: 15px;
  color: var(--ink-soft);
  text-align: center;
  min-height: 22px;
}

.help {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  color: var(--ink-soft);
  font-size: 13px;
  text-align: center;
}

.help p { margin: 0; }
.help strong { color: var(--ink); font-weight: 600; }

/* ---------- promos ---------- */

.promo {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.promo-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.promo-label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
}

.promo-link {
  color: var(--felt);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(29, 92, 68, 0.35);
}

.promo-link:hover {
  border-bottom-color: var(--felt);
}

.promo-btn {
  margin-left: auto;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.promo-btn:hover {
  color: var(--felt);
  border-color: rgba(29, 92, 68, 0.45);
}

.promo-slots {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: stretch;
}

.promo-card {
  flex: 1 1 220px;
  min-width: 200px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdf6;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.promo-card h3 {
  margin: 0;
  font-size: 17px;
  color: var(--felt);
}

.promo-card p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.promo-card a {
  margin-top: 6px;
  align-self: flex-start;
  font-size: 13px;
  font-weight: 600;
  color: #8a6c14;
  text-decoration: none;
  border-bottom: 1px solid rgba(138, 108, 20, 0.4);
}

.promo-card a:hover {
  border-bottom-color: #8a6c14;
}

.promo-frame {
  flex: 1 1 280px;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border: 1px dashed rgba(92, 58, 34, 0.35);
  border-radius: 14px;
  background: rgba(228, 215, 193, 0.45);
}

.promo-frame .frame-kicker {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.promo-frame ins {
  width: 100%;
}

.promo-thanks {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink-soft);
  font-size: 14px;
}

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--felt);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 620px) {
  body { padding: 16px 12px 28px; }
  .brand-text h1 { font-size: 23px; }
  .tagline { display: none; }
  .stat { padding: 8px 12px; }
  .stat-value { font-size: 18px; }
  .hint { font-size: 14px; }
  .promo-btn { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .overlay, .overlay-card { animation: none; }
  .primary-btn { transition: none; }
}
