/* =========================================================
   March to Rome - style.css
   Change the colours here to change the look of the whole game.
   ========================================================= */

:root {
  --terracotta: #c4572e;
  --terracotta-dark: #8f3a1a;
  --gold: #e3a92b;
  --gold-light: #f8e1a0;
  --red: #a61e22;
  --stone: #efe6d6;
  --stone-dark: #b9ab94;
  --ink: #3a2618;
  --paper: #fffaf0;
  --bg: #f1dfbd;
  --green: #2e8b3a;
  --heading-font: "Cinzel", "Trajan Pro", "Times New Roman", serif;
  --body-font: "Nunito", "Trebuchet MS", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: var(--body-font);
  font-size: 18px;
  line-height: 1.45;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.5), transparent 40%),
    repeating-linear-gradient(45deg, rgba(196, 87, 46, 0.06) 0 14px, transparent 14px 28px);
  min-height: 100vh;
}

[hidden] { display: none !important; }

h1, h2, h3 {
  font-family: var(--heading-font);
  color: var(--red);
  margin: 0.3em 0;
  line-height: 1.15;
}
h1 { font-size: clamp(2rem, 9vw, 3.4rem); letter-spacing: 0.03em; }
h2 { font-size: clamp(1.4rem, 5vw, 2rem); }

/* ---------- Screens and panels ---------- */
.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.panel {
  width: 100%;
  max-width: 560px;
  background: var(--paper);
  border: 4px solid var(--gold);
  border-radius: 22px;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 8px 0 var(--terracotta-dark), 0 14px 30px rgba(0, 0, 0, 0.2);
}
.panel.wide { max-width: 820px; text-align: left; }

.hero { width: 110px; height: 150px; display: block; margin: 0 auto; }
.tagline { font-size: 1.2rem; font-weight: 800; margin-top: 0; }
.hint, .small { font-size: 0.95rem; opacity: 0.8; }
.credits { font-family: var(--heading-font); font-weight: 700; color: var(--terracotta-dark); margin-bottom: 0; }
.label { font-weight: 900; margin: 18px 0 8px; }
.big-text { font-size: 1.2rem; }
.warning {
  background: #fde2dc;
  border: 2px solid var(--red);
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 800;
}

/* ---------- Buttons ---------- */
.btn, .choice {
  font-family: var(--body-font);
  font-weight: 900;
  font-size: 1.1rem;
  color: var(--ink);
  background: var(--stone);
  border: 3px solid var(--terracotta-dark);
  border-radius: 14px;
  min-height: 52px;
  padding: 10px 22px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--terracotta-dark);
  touch-action: manipulation;
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:hover, .choice:hover { filter: brightness(1.05); }
.btn:active, .choice:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--terracotta-dark); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.big { background: var(--terracotta); color: #fff; font-size: 1.3rem; min-height: 60px; }
.btn:focus-visible, .choice:focus-visible, .icon-btn:focus-visible, input:focus-visible {
  outline: 4px solid var(--gold);
  outline-offset: 2px;
}

.menu { display: flex; flex-direction: column; gap: 12px; margin: 18px auto; max-width: 320px; }
.menu.row { flex-direction: row; flex-wrap: wrap; justify-content: center; max-width: none; }

.choice-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.choice.selected { background: var(--gold-light); border-color: var(--red); box-shadow: 0 4px 0 var(--red); }
.choice.count { width: 64px; height: 64px; font-size: 1.6rem; padding: 0; }
.choice.level { flex: 1 1 200px; display: flex; flex-direction: column; gap: 4px; text-align: left; }
.choice.level strong { font-family: var(--heading-font); font-size: 1.3rem; color: var(--red); }
.choice.level span { font-weight: 700; font-size: 1rem; }

/* ---------- Volume sliders ---------- */
.volumes {
  display: grid;
  gap: 10px;
  background: var(--stone);
  border-radius: 14px;
  padding: 12px 16px;
  margin: 12px 0;
  text-align: left;
}
.volumes label { display: grid; gap: 2px; font-weight: 900; }
input[type="range"] { width: 100%; height: 36px; accent-color: var(--terracotta); cursor: pointer; }

/* ---------- Setup ---------- */
.name-list { display: grid; gap: 10px; }
.name-row { display: flex; align-items: center; gap: 10px; }
.mini-legionary { width: 42px; height: 58px; flex: none; }
.name-row input {
  flex: 1;
  min-width: 0;
  font-family: var(--body-font);
  font-size: 1.15rem;
  font-weight: 800;
  min-height: 52px;
  padding: 8px 14px;
  border: 3px solid var(--stone-dark);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}

/* ---------- Choose questions ---------- */
fieldset {
  border: 3px solid var(--gold);
  border-radius: 14px;
  margin: 0 0 14px;
  padding: 6px 12px 10px;
}
legend { font-family: var(--heading-font); font-weight: 900; color: var(--red); padding: 0 6px; }
.q-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 8px 4px;
  border-bottom: 1px dashed var(--stone-dark);
  cursor: pointer;
}
.q-item:last-child { border-bottom: 0; }
.q-item input { width: 26px; height: 26px; flex: none; margin-top: 2px; accent-color: var(--green); }
.q-item span { display: grid; font-weight: 700; }
.q-item small { color: var(--green); font-weight: 800; }

/* ---------- Game screen ---------- */
.screen.game { display: block; padding: 10px 12px 16px; }
.game-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 1300px;
  margin: 0 auto 8px;
}
.game-bar h2 { flex: 1; font-size: clamp(1.15rem, 4.5vw, 1.7rem); margin: 0; }
.badge {
  display: inline-block;
  font-family: var(--body-font);
  font-size: 0.8rem;
  vertical-align: middle;
  background: var(--gold);
  color: var(--ink);
  border-radius: 999px;
  padding: 2px 10px;
}
.icon-btn {
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 50%;
  border: 3px solid var(--terracotta-dark);
  background: var(--paper);
  color: var(--ink);
  font-size: 1.4rem;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 12px;
  align-items: start;
  max-width: 1300px;
  margin: 0 auto;
}
.board-wrap {
  border: 5px solid var(--terracotta-dark);
  border-radius: 16px;
  overflow: hidden;
  background: #a2cd6e;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}
#board { display: block; width: 100%; height: auto; max-height: calc(100dvh - 90px); }

.side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--paper);
  border: 4px solid var(--gold);
  border-radius: 18px;
  padding: 14px;
}
.turn { display: flex; align-items: center; gap: 10px; font-size: 1.25rem; }
.dot {
  display: inline-block;
  width: 20px;
  height: 20px;
  flex: none;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.3);
}
.dice-area { display: flex; align-items: center; gap: 14px; }
.dice-area .btn { flex: 1; }
.dice {
  width: 76px;
  height: 76px;
  flex: none;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  padding: 9px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--ink);
}
.pip { width: 14px; height: 14px; border-radius: 50%; background: var(--red); place-self: center; visibility: hidden; }
.pip.on { visibility: visible; }
.dice.rolling { animation: shake 0.16s infinite; }
@keyframes shake {
  0% { transform: rotate(0) translate(0, 0); }
  25% { transform: rotate(14deg) translate(2px, -3px); }
  50% { transform: rotate(-10deg) translate(-2px, 2px); }
  75% { transform: rotate(8deg) translate(1px, -2px); }
  100% { transform: rotate(0) translate(0, 0); }
}

.message { min-height: 2.9em; margin: 0; font-weight: 800; font-size: 1.1rem; }

.player-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.player-list li { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 10px; }
.player-list li.current { background: var(--gold-light); }
.player-name { flex: 1; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.where { font-size: 0.95rem; }

/* The legionary whose turn it is bobs up and down */
.token.active .bob { animation: bob 0.9s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-5px); } }

/* ---------- Pop-ups ---------- */
dialog.modal {
  width: calc(100% - 32px);
  max-width: 560px;
  max-height: calc(100dvh - 32px);
  overflow: auto;
  background: var(--paper);
  color: var(--ink);
  border: 5px solid var(--gold);
  border-radius: 22px;
  padding: 22px 20px;
  text-align: center;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
}
dialog::backdrop { background: rgba(40, 20, 10, 0.55); }
.kicker { margin: 0; font-weight: 900; color: var(--terracotta-dark); }
#q-text { font-family: var(--body-font); font-weight: 900; color: var(--ink); font-size: clamp(1.3rem, 5vw, 1.7rem); outline: none; }

.answers { display: flex; flex-direction: column; gap: 10px; margin: 16px 0 10px; }
.answer { display: flex; align-items: center; gap: 12px; text-align: left; }
.answer:disabled { opacity: 1; cursor: default; }
.answer .letter {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  background: var(--gold);
  color: var(--ink);
  font-family: var(--heading-font);
}
.answer.right { background: #c6ecb6; border-color: var(--green); box-shadow: 0 4px 0 var(--green); }
.answer.wrong { background: #f8c0b5; border-color: var(--red); box-shadow: 0 4px 0 var(--red); }
.feedback { font-weight: 900; font-size: 1.2rem; min-height: 1.4em; }
.feedback.good { color: var(--green); }
.feedback.bad { color: var(--red); }

.card-icon { font-size: 3.6rem; line-height: 1.1; }
.card-milestone { border-color: #8a8070; }
.card-shortcut { border-color: var(--green); background: #eefae8; }
.card-shortcut h2 { color: var(--green); }
.card-hazard { border-color: var(--red); background: #fdeeea; }

.howto { list-style: none; padding: 0; margin: 12px 0; text-align: left; display: grid; gap: 10px; }
.howto li { display: flex; gap: 12px; align-items: flex-start; font-weight: 700; }
.howto li > span:first-child { font-size: 1.5rem; width: 34px; flex: none; text-align: center; line-height: 1.1; }
.key { display: inline-block; width: 26px !important; height: 26px; border-radius: 6px; border: 3px solid; margin: 0 4px; }
.key.green { background: #bfe5ad; border-color: var(--green); }
.key.red { background: #f7b9ad; border-color: #b3261e; }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 10; }

/* ---------- Phones and small tablets ---------- */
@media (max-width: 820px) {
  .game-layout { grid-template-columns: minmax(0, 1fr); }
  #board { max-height: none; }
  .side { padding: 12px; }
  .message { min-height: 0; }
}
@media (max-width: 420px) {
  body { font-size: 17px; }
  .panel { padding: 18px 14px; }
  .btn { padding: 10px 16px; }
  .dice { width: 64px; height: 64px; padding: 7px; }
  .pip { width: 12px; height: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .token.active .bob, .dice.rolling { animation: none; }
}
