/* 7 Wonders Dice — theme
   Warm Mediterranean-Egyptian palette. Mobile-first. */

:root {
  /* base palette */
  --sand: #f5ead3;
  --sand-2: #efe0be;
  --gold: #d4a43c;
  --gold-dark: #a87e25;
  --brown: #3a2817;
  --brown-2: #5a3c22;
  --muted: #857157;

  /* building palette */
  --c-red: #c0392b;
  --c-blue: #2980b9;
  --c-yellow: #f1c40f;
  --c-green: #27ae60;
  --c-purple: #8e44ad;
  --c-white: #f5f5f5;
  --c-black: #2c3e50;
  --c-grey: #95a5a6;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 6px rgba(58, 40, 23, 0.12);
  --shadow-lg: 0 6px 18px rgba(58, 40, 23, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100vh;
  background: var(--sand);
  background-image:
    radial-gradient(circle at 20% 10%, rgba(212, 164, 60, 0.08), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(212, 164, 60, 0.06), transparent 50%);
  color: var(--brown);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3, h4, .screen-title {
  font-family: 'Cinzel', 'Trajan Pro', Georgia, serif;
  color: var(--brown);
  letter-spacing: 0.02em;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border-radius: var(--radius);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  min-height: 44px;
  padding: 10px 16px;
}

button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--gold);
  color: var(--brown);
  border: 1px solid var(--gold-dark);
  font-weight: 600;
  box-shadow: var(--shadow);
}

.btn-primary:hover { background: var(--gold-dark); color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--brown);
  border: 1px solid rgba(58, 40, 23, 0.2);
}

.btn-chip {
  background: var(--sand-2);
  color: var(--brown);
  border: 1px solid rgba(58, 40, 23, 0.15);
  border-radius: var(--radius-sm);
  min-height: 36px;
  padding: 6px 10px;
  font-size: 14px;
}

.btn-chip:hover { background: var(--gold); }

input[type="text"], input[type="number"], select {
  font-family: inherit;
  font-size: 16px;
  padding: 10px 12px;
  border: 1px solid rgba(58, 40, 23, 0.2);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--brown);
}

/* Screens */

.screen { display: none; padding: 16px; max-width: 960px; margin: 0 auto; }
.screen.active { display: block; }

.screen-title { margin: 0 0 4px; font-size: 1.8rem; }

.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;
}

/* Home */

.home-header { text-align: center; padding: 24px 0 8px; }
.home-header .screen-title { font-size: 2.4rem; color: var(--gold-dark); }
.home-subtitle { margin: 0; color: var(--muted); font-style: italic; }

.home-menu {
  display: grid; gap: 12px; margin: 24px 0; max-width: 380px; margin-inline: auto;
}

.home-menu button { width: 100%; }

.home-footer { text-align: center; margin-top: 24px; color: var(--muted); }
.home-footer small { font-size: 12px; }

/* Setup */

.stack { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; font-weight: 500; }
.stack input, .stack select { width: 100%; max-width: 320px; }
.stack fieldset { border: 1px solid rgba(58,40,23,0.15); border-radius: var(--radius-sm); padding: 8px 12px; }
.setup-actions { display: flex; gap: 12px; margin-top: 20px; flex-wrap: wrap; }

/* Game screen */

.game-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 12px;
}
.turn-counter { font-family: 'Cinzel', serif; font-size: 1.1rem; }
.turn-counter b { font-size: 1.5rem; color: var(--gold-dark); }

.banner {
  padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px;
  font-weight: 600;
}
.banner-endgame { background: rgba(192, 57, 43, 0.12); color: var(--c-red); border: 1px solid rgba(192,57,43,0.3); }

.game-body { display: grid; gap: 16px; }

/* Forum */

.forum-wrap { background: #fff; border: 1px solid rgba(58,40,23,0.1); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.forum { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.forum-section {
  background: var(--sand-2);
  border-radius: var(--radius-sm);
  padding: 8px;
  min-height: 120px;
  position: relative;
}
.forum-section-cost {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  color: var(--brown-2);
  text-align: center;
  padding-bottom: 6px;
  border-bottom: 1px dashed rgba(58,40,23,0.2);
  margin-bottom: 8px;
}
.forum-section-dice { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.forum-die {
  padding: 4px;
  background: transparent;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 64px;
}
.forum-die.picked { border-color: var(--gold); background: rgba(212,164,60,0.15); }
.forum-die-label { font-size: 10px; color: var(--muted); max-width: 64px; text-align: center; line-height: 1.1; }

/* Die */

.die {
  position: relative;
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; line-height: 1; font-weight: 700; color: #fff;
  user-select: none;
}
.die-face { z-index: 1; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.2)); }
.die-cb {
  position: absolute; bottom: 4px; right: 4px; width: 14px; height: 14px; opacity: 0.85;
}

.die-grey   { background: linear-gradient(160deg, #b3b9ba, var(--c-grey)); color: var(--brown); }
.die-red    { background: linear-gradient(160deg, #e05a4a, var(--c-red)); }
.die-blue   { background: linear-gradient(160deg, #4aa8e0, var(--c-blue)); }
.die-yellow { background: linear-gradient(160deg, #f7d84e, var(--c-yellow)); color: var(--brown); }
.die-green  { background: linear-gradient(160deg, #48d984, var(--c-green)); }
.die-purple { background: linear-gradient(160deg, #b16ad4, var(--c-purple)); }
.die-white  { background: linear-gradient(160deg, #ffffff, var(--c-white)); color: var(--brown); border: 2px solid var(--c-black); }
.die-black  { background: linear-gradient(160deg, #4a6279, var(--c-black)); }

/* Player strip */

.player-strip { display: grid; gap: 10px; grid-template-columns: 1fr; }
.player-card {
  background: #fff; border: 1px solid rgba(58,40,23,0.1); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow);
  display: grid; gap: 8px; grid-template-columns: 1fr auto auto; align-items: center;
}
.player-name { font-family: 'Cinzel', serif; font-size: 1.05rem; font-weight: 600; color: var(--brown); grid-column: 1; }
.player-specials { display: flex; gap: 4px; grid-column: 2; }
.player-bonuses { display: flex; gap: 4px; grid-column: 3; }
.player-actions { display: flex; gap: 6px; flex-wrap: wrap; grid-column: 1 / -1; }

.special-chip {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
  opacity: 0.25; border: 1px solid rgba(0,0,0,0.15);
}
.special-chip.active { opacity: 1; }
.special-chip.special-purple { background: var(--c-purple); }
.special-chip.special-black { background: var(--c-black); }
.special-chip.special-white { background: #fff; color: var(--brown); border-color: var(--brown); }

.bonus-dot {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--gold-dark);
  background: transparent;
}
.bonus-dot.filled { background: var(--gold); }

/* Robot panel */

.robot-panel {
  background: #fff; border: 1px solid rgba(58,40,23,0.1); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow);
}
.robot-panel header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.robot-board { color: var(--muted); font-size: 0.9rem; }
.robot-stats {
  display: grid; gap: 4px 16px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  font-size: 14px; margin-bottom: 10px;
}
.robot-action {
  background: var(--sand-2); border-radius: var(--radius-sm); padding: 8px 12px; margin-top: 10px;
}
.robot-action h4 { margin: 0 0 4px; }
.robot-action ul { margin: 6px 0 0; padding-left: 20px; }
.robot-action li { font-size: 13px; }

/* Human tracking */

.human-tracking { background: #fff; border: 1px solid rgba(58,40,23,0.1); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.counter-grid { display: grid; gap: 8px; grid-template-columns: 1fr; }
.counter-row {
  display: grid; grid-template-columns: 1fr auto auto auto;
  align-items: center; gap: 8px;
}
.counter-label { font-weight: 500; }
.counter-val { min-width: 56px; text-align: center; }

/* Endgame */

.endgame {
  margin-top: 20px; background: #fff; border-radius: var(--radius); padding: 16px;
  border: 2px solid var(--gold); box-shadow: var(--shadow-lg);
}
.endgame-result { margin-top: 12px; }
.endgame-result .big { font-size: 1.4rem; margin: 4px 0; }

.scoring-table {
  border-collapse: collapse; margin-top: 8px;
}
.scoring-table td {
  padding: 4px 10px; border-bottom: 1px dashed rgba(58,40,23,0.12);
}
.scoring-table tr.achieved {
  background: rgba(212,164,60,0.15); font-weight: 600;
}

/* Rules */

.rules-header { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.rules-tabs {
  display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid rgba(58,40,23,0.15);
  margin-bottom: 14px;
}
.rules-tabs button {
  background: transparent; border: none; padding: 8px 14px; border-bottom: 3px solid transparent;
  color: var(--brown); white-space: nowrap; font-weight: 500; border-radius: 0;
}
.rules-tabs button.active { border-color: var(--gold); color: var(--gold-dark); font-weight: 700; }
.rules-body [data-tab-panel] { display: none; }
.rules-body [data-tab-panel].active { display: block; }
.rules-body h3 { color: var(--gold-dark); margin-top: 0; }
.rules-body h4 { margin-top: 18px; color: var(--brown-2); }
.rules-body ul, .rules-body ol { padding-left: 22px; }
.rules-body li { margin: 4px 0; }

/* Settings */

.setting-row {
  display: flex; align-items: center; gap: 10px; margin: 10px 0;
  font-weight: 500;
}

/* Misc */

.muted { color: var(--muted); }
.small { font-size: 0.9rem; }

/* Confetti */

.confetti-layer {
  position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 9999;
}
.confetti-piece {
  position: absolute; top: -10px; width: 10px; height: 18px;
  animation: confetti-fall linear forwards;
  transform: rotate(0deg);
}
@keyframes confetti-fall {
  to { transform: translateY(110vh) rotate(720deg); }
}

.no-anim *, .no-anim *::before, .no-anim *::after {
  animation-duration: 0.001ms !important; animation-delay: 0ms !important;
  transition-duration: 0.001ms !important; transition-delay: 0ms !important;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important; transition-duration: 0.001ms !important;
  }
}

/* Responsive */

@media (min-width: 720px) {
  .player-strip { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .game-body { grid-template-columns: 1fr; }
  .home-menu { max-width: 480px; }
}

@media (min-width: 1024px) {
  .game-body {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "forum forum"
      "robot human"
      "players players";
  }
  .forum-wrap { grid-area: forum; }
  .robot-panel { grid-area: robot; }
  .human-tracking { grid-area: human; }
  .player-strip { grid-area: players; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}
