:root {
  --bg-deep: #0d2231;
  --bg-mid: #18455f;
  --panel: rgba(242, 247, 252, 0.96);
  --ink: #152634;
  --muted: #5f7182;
  --line: rgba(21, 38, 52, 0.12);
  --shadow: 0 22px 48px rgba(3, 11, 24, 0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 10%, rgba(180, 212, 240, 0.18), transparent 22%),
    radial-gradient(circle at 84% 12%, rgba(88, 133, 177, 0.18), transparent 22%),
    linear-gradient(155deg, var(--bg-deep), var(--bg-mid));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.03), transparent 28%),
    linear-gradient(rgba(255, 255, 255, 0.02) 0, rgba(255, 255, 255, 0.02) 1px, transparent 1px, transparent 80px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 0, rgba(255, 255, 255, 0.02) 1px, transparent 1px, transparent 80px);
  opacity: 0.32;
  pointer-events: none;
}

.domino-app {
  width: min(1220px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.domino-topbar,
.domino-controls-panel,
.domino-board-panel,
.player-card,
.rules-card,
.result-overlay-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.domino-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-radius: 24px;
}

.domino-topbar-actions { display: flex; align-items: center; gap: 12px; }
.domino-brand { display: inline-flex; align-items: center; gap: 14px; color: var(--ink); text-decoration: none; }
.domino-brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #f1f6fb, #5f95c0);
  color: #12212d;
  font-weight: 900;
}
.domino-brand-copy { display: grid; gap: 2px; }
.domino-brand-copy strong { font-size: 1.04rem; }
.domino-brand-copy span { color: var(--muted); font-size: 0.92rem; }

.domino-return,
.domino-support,
.action-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid rgba(21, 34, 55, 0.12);
  background: linear-gradient(145deg, #f8fbff, #dfe8f2);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease;
}

.domino-support { background: linear-gradient(145deg, #ffdc42, #f0b90a); color: #24150f; }
.action-button.primary { background: linear-gradient(145deg, #dceaf7, #6c9fcb); color: #12212d; }
.domino-return:hover,
.domino-return:focus-visible,
.domino-support:hover,
.domino-support:focus-visible,
.action-button:hover,
.action-button:focus-visible { transform: translateY(-1px); }
.action-button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.domino-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(360px, 1.08fr);
  gap: 20px;
  align-items: start;
  padding: 28px 0 18px;
}

.eyebrow {
  margin: 0 0 12px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow.dark { color: #456278; }

.domino-copy h1,
.status-copy h2,
.rules-card h2,
.result-overlay-card h2 {
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
}

.domino-copy h1 {
  margin: 0 0 14px;
  max-width: 10ch;
  color: #fff8ec;
  font-size: clamp(2.5rem, 5vw, 4.7rem);
  line-height: 0.95;
}

.domino-copy p:last-child {
  margin: 0;
  max-width: 60ch;
  color: rgba(239, 245, 255, 0.86);
  line-height: 1.65;
}

.domino-controls-panel { border-radius: 30px; padding: 22px; }
.status-copy h2 { margin: 0; font-size: clamp(1.28rem, 2.4vw, 1.82rem); line-height: 1.12; }
.notice-text,
.mode-hint { margin: 10px 0 0; color: var(--muted); line-height: 1.55; }

.setup-panel { display: grid; gap: 18px; margin-top: 18px; }
.setup-group { display: grid; gap: 12px; }
.setup-label {
  margin: 0;
  color: #425069;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.mode-options { display: flex; flex-wrap: wrap; gap: 10px; }
.choice-pill { position: relative; display: inline-flex; min-height: 48px; align-items: center; }
.choice-pill input { position: absolute; opacity: 0; pointer-events: none; }
.choice-pill span,
.select-input {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid rgba(21, 34, 55, 0.12);
  border-radius: 18px;
  background: linear-gradient(145deg, #f9fbff, #e8eff7);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}
.choice-pill input:checked + span {
  background: linear-gradient(145deg, #d9ebfb, #6e9fca);
  color: #12212d;
}

.select-field { display: grid; gap: 10px; }
.select-input { width: 100%; appearance: none; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.metric-card {
  display: grid;
  gap: 4px;
  padding: 15px 16px;
  border-radius: 22px;
  background: linear-gradient(145deg, #eef5fc, #e1eaf4);
}

.metric-card span { color: var(--muted); font-size: 0.82rem; font-weight: 700; }
.metric-card strong { font-size: clamp(1.26rem, 2.6vw, 1.7rem); }

.action-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }

.domino-layout {
  display: grid;
  gap: 16px;
}

.player-card,
.domino-board-panel,
.rules-card { border-radius: 26px; padding: 18px 20px; }

.player-head { margin-bottom: 12px; }
.player-name { margin: 0; font-weight: 800; font-size: 1.02rem; }
.player-role { margin: 4px 0 0; color: var(--muted); }

.hand-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 88px;
}

.domino-board-panel { min-height: 180px; }
.domino-board {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-height: 132px;
}

.domino-start-hint {
  color: var(--muted);
  line-height: 1.6;
}

.domino-anchor {
  min-height: 54px;
  padding: 0 16px;
  border-radius: 18px;
  border: 1px dashed rgba(21, 34, 55, 0.22);
  background: rgba(111, 159, 202, 0.12);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.domino-tile {
  display: inline-flex;
  align-items: stretch;
  width: 86px;
  height: 46px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(145deg, #fffef8, #ece8d9);
  box-shadow: 0 10px 22px rgba(8, 17, 13, 0.18);
  color: #152634;
}

.domino-tile.is-playable {
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.domino-tile.is-playable:hover,
.domino-tile.is-playable:focus-visible,
.domino-tile.is-selected {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(8, 17, 13, 0.24);
}

.domino-tile.is-double {
  width: 46px;
  height: 86px;
  flex-direction: column;
}

.domino-half {
  flex: 1;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.domino-half strong {
  font-size: 1.2rem;
}

.domino-divider {
  width: 2px;
  background: rgba(21, 38, 52, 0.16);
}

.domino-tile.is-double .domino-divider {
  width: auto;
  height: 2px;
}

.result-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 16, 27, 0.62);
  z-index: 60;
}

.result-overlay[hidden] { display: none !important; }
.result-overlay-card { width: min(460px, 100%); text-align: center; }
.overlay-kicker {
  margin: 0 0 12px;
  color: #4f6f8a;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.result-overlay-card h2 { margin: 0 0 12px; font-size: clamp(1.8rem, 4vw, 2.4rem); }
.overlay-message,
.overlay-details { margin: 0 0 14px; color: var(--muted); line-height: 1.6; }

.domino-seo {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.rules-card h2 { margin: 0 0 14px; font-size: 1.24rem; }
.rules-card p,
.rules-card li,
.faq-list dd { color: var(--muted); line-height: 1.65; }
.rules-card ol,
.rules-card ul { margin: 0; padding-left: 20px; }
.faq-list { margin: 0; display: grid; gap: 10px; }
.faq-list dt { font-weight: 800; }
.faq-list dd { margin: 0; }

@media (max-width: 1080px) {
  .domino-hero,
  .domino-seo { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .domino-app { width: min(100% - 18px, 100%); padding-top: 14px; }
  .domino-topbar { flex-direction: column; align-items: stretch; }
  .domino-topbar-actions,
  .action-row { flex-direction: column; width: 100%; }
  .metric-grid { grid-template-columns: 1fr; }
}
