:root{
  --bg: #3d2c33;
  --bg-vignette: #2c1f24;
  --panel: #2f2126;
  --manila: #d3dde3;
  --manila-shadow: #aebcc4;
  --ink: #1f2c33;
  --ink-soft: #b39a8a;
  --paper-light: #eef2f5;
  --olive: #a8894f;
  --olive-dark: #4a2f35;
  --stamp-red: #7c2530;
  --stamp-red-dark: #591b23;
  --gold: #c9a24d;
  --cream: #f0e6d6;
}

* { box-sizing: border-box; }

html {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-vignette);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 32px 16px 60px;
  color: var(--cream);
  font-family: 'Nunito', sans-serif;
  background-image:
    radial-gradient(ellipse at 50% 30%, rgba(61,44,51,0.6) 0%, rgba(44,31,36,0.72) 75%),
    url("assets/wallpaper.svg");
  background-repeat: no-repeat, repeat;
  background-size: auto, 480px 480px;
  background-attachment: fixed, fixed;
}

.sheet {
  width: 100%;
  max-width: 560px;
}

/* ---------- Header / memo strip ---------- */
.memo-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border-bottom: 2px solid var(--olive);
  padding-bottom: 14px;
  margin-bottom: 6px;
  gap: 8px;
}

.memo-head .eyebrow {
  position: relative;
  top: -0.4cm;
  z-index: 2;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--olive);
}

h1 {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-size: clamp(30px, 6vw, 44px);
  line-height: 0.92;
  margin: 4px 0 0;
  color: var(--cream);
  text-transform: uppercase;
  position: relative;
  display: inline-block;
}

h1 .stamp-tilt {
  display: inline-block;
  transform: rotate(-2deg);
  color: var(--stamp-red);
  -webkit-text-stroke: 1.5px var(--stamp-red-dark);
}

.corp-c-wrap {
  position: relative;
  display: inline-block;
}

.lurking-clown {
  position: absolute;
  top: -22px;
  left: -16px;
  width: 46px;
  height: auto;
  transform: rotate(-6deg);
  z-index: 0;
  pointer-events: none;
}

.corp-c {
  position: relative;
  z-index: 1;
}

.subhead {
  font-size: 13px;
  color: var(--ink-soft);
  max-width: 400px;
  text-align: center;
  line-height: 1.5;
}

.subhead b { color: var(--cream); font-weight: 600; }

/* ---------- Controls row ---------- */
.controls {
  display: flex;
  gap: 10px;
  margin: 18px 0 24px;
  flex-wrap: wrap;
}

button {
  font-family: 'Nunito', sans-serif;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 3px;
  border: 1px solid var(--olive);
  background: var(--panel);
  color: var(--cream);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, border-color .15s ease;
}

button:hover { border-color: var(--gold); color: var(--gold); }
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.primary {
  background: var(--stamp-red);
  border-color: var(--stamp-red-dark);
  color: var(--cream);
}
button.primary:hover { background: var(--stamp-red-dark); color: var(--cream); border-color: var(--gold); }

/* ---------- Bingo banner ---------- */
.bingo-banner {
  display: none;
  align-items: center;
  gap: 12px;
  border: 2px solid var(--gold);
  background: rgba(201, 162, 77, 0.08);
  color: var(--gold);
  font-family: 'Fredoka', sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 18px;
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 20px;
}
.bingo-banner.show { display: flex; animation: bannerIn 0.35s ease-out; }
.bingo-banner small {
  font-family: 'Nunito', sans-serif;
  text-transform: none;
  letter-spacing: normal;
  font-size: 11px;
  color: var(--cream);
  font-weight: 400;
}

@keyframes bannerIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Lose banner ---------- */
.lose-banner {
  display: none;
  align-items: center;
  gap: 12px;
  border: 2px solid var(--stamp-red);
  background: rgba(124, 37, 48, 0.12);
  color: var(--stamp-red);
  font-family: 'Fredoka', sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 18px;
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 20px;
}
.lose-banner.show { display: flex; animation: bannerIn 0.35s ease-out; }
.lose-banner small {
  font-family: 'Nunito', sans-serif;
  text-transform: none;
  letter-spacing: normal;
  font-size: 11px;
  color: var(--cream);
  font-weight: 400;
}

/* ---------- Board ---------- */
.board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  background: linear-gradient(155deg, var(--paper-light) 0%, var(--manila) 55%, var(--manila-shadow) 100%);
  border-radius: 2px;
  padding: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  box-shadow:
    inset 0 0 0 1px rgba(44,40,18,0.15),
    0 2px 0 rgba(0,0,0,0.25);
  overflow: hidden;
  user-select: none;
  transition: transform 0.08s ease;
}

.tile:hover { transform: translateY(-1px); }
.tile:active { transform: translateY(0); }

.tile::before {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 0; height: 0;
  border-style: solid;
  border-width: 0 10px 10px 0;
  border-color: transparent rgba(44,40,18,0.18) transparent transparent;
}

.tile-text {
  font-size: clamp(13px, 2.66vw, 15px);
  line-height: 1.25;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0.01em;
  position: relative;
  z-index: 1;
}

.tile.marked .tile-text { color: rgba(44,40,18,0.35); }

.stamp {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  z-index: 2;
}

.tile.marked .stamp { opacity: 1; }

.stamp-mark {
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(11px, 2.6vw, 15px);
  letter-spacing: 0.03em;
  color: var(--stamp-red);
  border: 2.5px solid var(--stamp-red);
  padding: 2px 6px;
  border-radius: 4px;
  transform: rotate(-14deg) scale(1);
  text-transform: uppercase;
  mix-blend-mode: multiply;
  background: rgba(255,255,255,0.02);
}

.tile.marked .stamp-mark {
  animation: stampDown 0.22s cubic-bezier(.36,1.8,.55,1) both;
}

@keyframes stampDown {
  0%   { opacity: 0; transform: rotate(-14deg) scale(2.2); }
  60%  { opacity: 1; transform: rotate(-14deg) scale(0.92); }
  100% { opacity: 1; transform: rotate(-14deg) scale(1); }
}

.tile.bingo-line {
  box-shadow:
    inset 0 0 0 1px rgba(44,40,18,0.15),
    0 0 0 2px var(--gold),
    0 2px 0 rgba(0,0,0,0.25);
}

/* ---------- Footer note ---------- */
.footnote {
  margin-top: 22px;
  font-size: 11px;
  color: var(--ink-soft);
  text-align: center;
  letter-spacing: 0.04em;
}

/* ---------- Add-a-phrase panel ---------- */
.phrase-add {
  border: 1px solid var(--olive-dark);
  background: var(--panel);
  border-radius: 4px;
  padding: 21px 24px;
  margin-bottom: 22px;
  position: fixed;
  top: 24px;
  left: 24px;
  width: 390px;
  z-index: 10;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}

@media (max-width: 1100px) {
  .phrase-add {
    position: static;
    width: auto;
    box-shadow: none;
  }
}

.phrase-add-label {
  font-size: 16px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--olive);
  margin-bottom: 15px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.phrase-add-label.dragging {
  cursor: grabbing;
}

.phrase-add-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.phrase-add-row input {
  flex: 1 1 220px;
  font-family: 'Nunito', sans-serif;
  font-size: 19px;
  padding: 15px 18px;
  border-radius: 3px;
  border: 1px solid var(--olive);
  background: var(--bg);
  color: var(--cream);
}

.phrase-add-row input::placeholder { color: var(--ink-soft); }
.phrase-add-row input:focus { outline: none; border-color: var(--gold); }

.phrase-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 18px;
}

.phrase-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 18px;
  background: var(--olive-dark);
  color: var(--cream);
  border-radius: 3px;
  padding: 8px 9px 8px 15px;
}

.phrase-chip button {
  all: unset;
  cursor: pointer;
  color: var(--cream);
  opacity: 0.6;
  font-size: 21px;
  line-height: 1;
  padding: 3px 6px;
}
.phrase-chip button:hover { opacity: 1; color: var(--stamp-red); }

.phrase-pool-count {
  margin-top: 15px;
  font-size: 16px;
  color: var(--ink-soft);
}

.phrase-add-note {
  font-size: 16px;
  color: var(--ink-soft);
  margin-top: 9px;
}

/* ---------- Call timer panel ---------- */
.timer-panel {
  border: 1px solid var(--olive-dark);
  background: var(--panel);
  border-radius: 4px;
  padding: 14px 16px;
  margin-bottom: 22px;
  position: fixed;
  top: 24px;
  right: 24px;
  width: 220px;
  z-index: 10;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}

@media (max-width: 900px) {
  .timer-panel {
    position: static;
    width: auto;
    box-shadow: none;
  }
}

.timer-panel-label {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--olive);
  margin-bottom: 10px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.timer-panel-label.dragging {
  cursor: grabbing;
}

.timer-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.timer-row input[type="range"] {
  flex: 1 1 auto;
  accent-color: var(--gold);
}

.timer-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.timer-presets button {
  padding: 5px 10px;
  font-size: 10px;
}

.timer-display {
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(28px, 6vw, 40px);
  letter-spacing: 0.04em;
  color: var(--gold);
  text-align: center;
  margin: 14px 0 12px;
  transition: color 0.2s ease;
}

.timer-display.timer-done {
  color: var(--stamp-red);
  animation: timerPulse 0.6s ease-in-out infinite;
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.timer-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
}

@media (max-width: 480px) {
  .tile { padding: 5px; }
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
}
