:root {
  --outline: #46230a;
  --panel: #fff0cd;
  --panel-text: #6e370f;
  --page: #f6e7c4;
  --orange: #f08c28;
  --green: #3fa34d;
  --blue: #3b82d6;
  --grey: #a0a0a0;
  --red: #d9453b;
  --font: ui-rounded, "Arial Rounded MT Bold", "Nunito", "Trebuchet MS", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--page);
  font-family: var(--font);
  font-weight: 800;
  color: var(--panel-text);
  -webkit-tap-highlight-color: transparent;
}

h1 { margin: 0; font-size: clamp(48px, 13vmin, 96px); line-height: 1; color: var(--red); }
h2 { margin: 0 0 8px; font-size: 26px; text-align: center; }
p { margin: 0; }

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px 16px;
  text-align: center;
}
.lead { max-width: 440px; font-size: 18px; font-weight: 600; }

.card {
  width: min(100%, 400px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel);
  border: 4px solid var(--outline);
  border-radius: 24px;
  padding: 18px;
}
.card label, .label { font-size: 16px; }
.or { margin-top: 6px; font-size: 15px; opacity: 0.75; }
.joinRow { display: flex; gap: 10px; }
.joinRow input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: 0.2em; }
.code { font-size: 52px; letter-spacing: 0.18em; color: var(--red); line-height: 1; }

input {
  font: inherit;
  font-size: 22px;
  text-align: center;
  color: var(--panel-text);
  background: #fff;
  border: 3px solid var(--outline);
  border-radius: 14px;
  padding: 9px;
}

/* Which dice a new game uses */
.choice { display: flex; gap: 8px; }
.choice label {
  flex: 1;
  font-size: 15px;
  padding: 8px 6px;
  background: #fff;
  border: 3px solid var(--outline);
  border-radius: 14px;
  cursor: pointer;
}
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice label:has(input:checked) { background: var(--green); color: #fff; }
.choice label:has(input:focus-visible) { outline: 3px solid var(--blue); }
#side #rollButton { font-size: 24px; padding: 12px 20px; align-self: flex-start; }

.buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.button {
  font: inherit;
  font-size: 19px;
  color: #fff;
  background: var(--orange);
  border: 3px solid var(--outline);
  border-radius: 16px;
  padding: 8px 20px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-shadow: -1px -1px 0 var(--outline), 1px -1px 0 var(--outline), -1px 1px 0 var(--outline), 1px 1px 0 var(--outline);
}
.button:active { transform: translateY(2px); }
.button.green { background: var(--green); }
.button.blue { background: var(--blue); }
.button.grey { background: var(--grey); }
.link { font: inherit; font-size: 15px; color: var(--blue); background: none; border: 0; text-decoration: underline; cursor: pointer; }
.message { min-height: 1.3em; font-size: 16px; }

.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; text-align: left; }
.players li { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 12px; font-size: 18px; border: 3px solid transparent; }
.players li.turn { background: #fff; border-color: var(--outline); }
.players li.left { opacity: 0.45; text-decoration: line-through; }
.players .dot { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--outline); background: var(--grey); flex: none; }
.players .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The game: board with the panel beside it, or below it on an upright phone */
#play { height: 100dvh; display: flex; }
#board { flex: none; width: min(100vw, 100dvh); height: min(100vw, 100dvh); touch-action: manipulation; }
#side { flex: 1; min-width: 0; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px; }
@media (orientation: portrait) {
  #play { flex-direction: column; }
}
#status { font-size: 20px; min-height: 2.4em; }
#lastRoll { display: flex; align-items: center; gap: 12px; }
#rollPhoto { width: 72px; height: 72px; border-radius: 12px; border: 3px solid var(--outline); object-fit: cover; }
#rollText { font-size: 15px; font-weight: 600; text-align: left; }
#log { list-style: none; margin: 0; padding: 0; font-size: 14px; font-weight: 600; opacity: 0.8; }
#side .buttons { justify-content: flex-start; margin-top: auto; }
#side .button { font-size: 16px; padding: 6px 14px; }

.die {
  flex: none;
  width: 72px;
  height: 72px;
  padding: 9px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  background: #fff;
  border: 4px solid var(--outline);
  border-radius: 16px;
}
.die i { border-radius: 50%; }
.die i.on { background: var(--outline); }

/* Camera window */
.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 12px; background: rgba(70, 35, 10, 0.45); }
.window {
  width: min(100%, 380px);
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 4px solid var(--outline);
  border-radius: 24px;
  padding: 14px;
  text-align: center;
}
.view { position: relative; width: min(100%, 46dvh); aspect-ratio: 1; border-radius: 16px; border: 3px solid var(--outline); overflow: hidden; background: #222; }
.view video, .view canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.progress { width: 100%; height: 10px; border-radius: 5px; background: rgba(70, 35, 10, 0.15); overflow: hidden; }
#cameraProgress { height: 100%; width: 0; background: var(--green); transition: width 0.12s linear; }
#manual p { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.numbers { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.numbers .button { padding: 8px 0; }
