/* Dice Roller - one screen: dice, result, Roll, how many dice. */

:root {
  --gof-primary-dark: #157623;
  --gof-primary: #9bca3e;
  --gof-bg-light: #dde5ed;
  --gof-bg-mint: #defff0;
  --text-primary: #2f2c28;
  --text-secondary: #5e5c5e;
  --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Arimo', sans-serif;
  color: var(--text-primary);
  background: linear-gradient(180deg, var(--gof-bg-light) 0%, var(--gof-bg-mint) 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#app {
  flex: 1;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

/* ===== Shared header bar (per HEADER_SPECS) ===== */
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  margin-bottom: 0.25rem;
  padding: 4px 0;
  gap: 12px;
  position: relative;
  z-index: 1100;
}

.header-left { flex: 1; min-width: 0; max-width: 85%; }
.header-right { flex-shrink: 0; min-width: 52px; }

.game-title-wrap { position: relative; display: inline-block; }

.game-title-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
}

.game-title-heading {
  margin: 0;
  font-family: 'League Spartan', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.game-title-chevron {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.game-title-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  min-width: 160px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 100;
}

.game-title-dropdown[aria-hidden="false"] { display: block; }

.game-nav-link {
  display: block;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--text-primary);
  text-decoration: none;
  border-bottom: 1px solid #e2e8f0;
}

.game-nav-link:last-child { border-bottom: none; }
.game-nav-link:hover { background: var(--gof-bg-mint); }

/* ===== The dice ===== */
.roller {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.dice-well {
  width: 100%;
  max-width: 480px;
  padding: 1.25rem 0.75rem 0.5rem;
  background: white;
  border-radius: 16px;
  box-shadow: var(--card-shadow);
}

.gof-dice-stage { cursor: pointer; -webkit-tap-highlight-color: transparent; }

/* A held die: green border and pips on a mint face. */
.gof-dice-stage.is-held {
  --gof-dice-border: var(--gof-primary-dark);
  --gof-dice-pip: var(--gof-primary-dark);
}

.gof-dice-stage.is-held .gof-dice-face {
  background: var(--gof-bg-mint);
  border-width: 4px;
}

.dice-hint {
  margin-top: 0.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* --gof-dice-size is set on this element by shared/dice.js. Three to a row, and
   two rows of height reserved so 1 die and 6 dice take the same space. */
.dice-tray {
  max-width: calc(var(--gof-dice-size, 88px) * 3 + 2rem);
  min-height: calc(var(--gof-dice-size, 88px) * 2 + 1rem);
  margin: 0 auto;
  align-content: center;
}

/* ===== Result ===== */
.status-area {
  width: 100%;
  max-width: 480px;
  min-height: 2.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: 'League Spartan', sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.2;
  color: var(--text-primary);
}

/* ===== Buttons ===== */
.play-actions {
  width: 100%;
  max-width: 380px;
}

.primary-btn {
  width: 100%;
  font-family: 'Arimo', sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  padding: 0.75rem 1.25rem;
  min-height: 56px;
  border-radius: 8px;
  cursor: pointer;
  background: var(--gof-primary-dark);
  color: white;
  border: 2px solid var(--gof-primary-dark);
  transition: background 0.15s, transform 0.1s;
}

.primary-btn:hover { background: #11631d; }
.primary-btn:active { transform: scale(0.97); }
.primary-btn:disabled { cursor: default; transform: none; }

/* ===== How many dice ===== */
.count-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.count-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.choice-row { display: flex; gap: 6px; }

.choice-btn {
  width: 44px;
  height: 44px;
  font-family: 'Arimo', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  background: white;
  color: var(--text-secondary);
  border: 1.5px solid #d1d5db;
  border-radius: 999px;
  cursor: pointer;
}

.choice-btn:hover { border-color: var(--gof-primary); background: var(--gof-bg-mint); }

.choice-btn[aria-pressed="true"] {
  background: var(--gof-bg-mint);
  color: var(--gof-primary-dark);
  border-color: var(--gof-primary-dark);
  border-width: 2px;
}

.quiet-btn {
  font-family: 'Arimo', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.quiet-btn:hover { color: var(--text-primary); }

/* ===== Roll history ===== */
.history {
  width: 100%;
  max-width: 480px;
  background: white;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.history-toggle {
  padding: 0.75rem 1rem;
  font-family: 'League Spartan', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}

.history-body {
  padding: 0 1rem 0.5rem;
  text-align: center;
}

.history-note {
  margin-bottom: 0.5rem;
  text-align: left;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.history-note[hidden] { display: none; }

.history-list { list-style: none; }

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-top: 1px solid #e2e8f0;
}

.history-row:first-child {
  background: var(--gof-bg-mint);
  border-top: none;
  border-radius: 8px;
}

.history-dice { display: flex; gap: 4px; }

.mini-die {
  width: 26px;
  height: 26px;
  padding: 3px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 1px;
  background: white;
  border: 1.5px solid var(--text-primary);
  border-radius: 5px;
}

.mini-pip {
  border-radius: 50%;
  background: var(--text-primary);
}

.history-total {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  white-space: nowrap;
}

.quiet-btn[hidden] { display: none; }

.tool-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.secondary-btn {
  font-family: 'Arimo', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.5rem 0.9rem;
  min-height: 44px;
  border-radius: 8px;
  cursor: pointer;
  background: white;
  color: var(--gof-primary-dark);
  border: 2px solid var(--gof-primary-dark);
}

.secondary-btn:hover { background: var(--gof-bg-mint); }

/* ===== Full screen ===== */
body.is-fullscreen { overflow: hidden; }

body.is-fullscreen .roller {
  position: fixed;
  inset: 0;
  z-index: 5000;
  justify-content: center;
  padding: 2.5rem 1rem 1rem;
  background: linear-gradient(180deg, var(--gof-bg-light) 0%, var(--gof-bg-mint) 100%);
}

body.is-fullscreen .dice-well {
  max-width: none;
  background: none;
  box-shadow: none;
  padding: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* The 3D cube draws a little larger than its box, so big dice need a bigger gap. */
body.is-fullscreen .dice-tray {
  min-height: 0;
  gap: calc(var(--gof-dice-size, 88px) * 0.2);
  max-width: calc(var(--gof-dice-size, 88px) * 3.4 + 1px);
}
body.is-fullscreen .dice-hint { display: none; }

.roller-exit {
  position: absolute;
  top: 0.25rem;
  right: 0.5rem;
}

/* ===== Guide ===== */
.guide {
  width: 100%;
  margin-top: 1rem;
  padding: 1.25rem 1.25rem 1.5rem;
  background: white;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.guide h2 {
  font-family: 'League Spartan', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1.25;
  color: var(--text-primary);
  margin: 1.6rem 0 0.6rem;
}

.guide h2:first-child { margin-top: 0; }
.guide p { margin-bottom: 0.75rem; }
.guide strong { color: var(--text-primary); }
.guide a { color: var(--gof-primary-dark); font-weight: 600; }

.guide-steps,
.guide-list {
  margin: 0 0 0.9rem;
  padding-left: 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.guide-steps li::marker { font-weight: 700; color: var(--gof-primary-dark); }

/* Wide content scrolls inside its own box rather than the page. */
.guide-table-wrap {
  overflow-x: auto;
  margin: 0 0 0.9rem;
  -webkit-overflow-scrolling: touch;
}

.guide-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.guide-table th,
.guide-table td {
  padding: 0.5rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

.guide-table th {
  font-family: 'League Spartan', sans-serif;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--gof-bg-mint);
}

.guide-table td + td,
.guide-table th + th { text-align: right; }

.guide-faq { display: flex; flex-direction: column; gap: 0.4rem; }

.guide-faq details {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
}

.guide-faq summary {
  list-style: none;
  padding: 0.65rem 0.85rem;
  font-family: 'League Spartan', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}

.guide-faq summary::-webkit-details-marker { display: none; }
.guide-faq summary::after { content: ' \25BE'; color: var(--text-secondary); font-size: 0.75rem; }
.guide-faq details[open] summary::after { content: ' \25B4'; }
.guide-faq summary:hover { background: var(--gof-bg-mint); }
.guide-faq details p { padding: 0 0.85rem 0.75rem; margin: 0; }

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--gof-primary-dark);
  text-decoration: none;
  font-weight: 600;
}

.footer-links a:hover { text-decoration: underline; }
