@import url('https://fonts.googleapis.com/css2?family=Libre+Franklin:wght@400;600;700&family=Playfair+Display:wght@700&display=swap');

:root {
  color-scheme: light;
  --bg: #f7f4ef;
  --bg-accent: #f0e6d6;
  --ink: #1d1b16;
  --muted: #5b544b;
  --panel: #ffffff;
  --accent: #c45f2a;
  --accent-dark: #8f3f1b;
  --success: #2e6b4f;
  --danger: #a2332b;
  --shadow: 0 24px 50px rgba(29, 27, 22, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'interstate-mono', monospace;
  font-size: 100%;
  font-weight: 300;
  color: var(--ink);
  background: radial-gradient(circle at top left, #fff5e6 0%, var(--bg) 40%),
    repeating-linear-gradient(45deg, rgba(196, 95, 42, 0.08) 0 6px, rgba(255, 255, 255, 0) 6px 12px);
}

.page {
  padding: 0 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  row-gap: 12px;
  column-gap: 0;
  text-align: center;
}

.tcb-slogan {
  text-transform: uppercase;
  font-family: 'interstate-mono', monospace;
  font-weight: 400;
  font-size: 12px;
  margin-top: 0.75em;
  color: #726969;
}

h1 {
  font-family: 'matrix-ii-ext-semi-narrow', serif;
  font-size: 3rem;
  font-weight: 500;
  line-height: 1.1;
  max-width: 960px;
  margin: 0 auto 8px;
  text-align: center;
}

.subhead {
  max-width: 700px;
  font-family: 'interstate-mono', monospace;
  font-weight: 400;
  font-size: 13px;
  margin-top: 0.75em;
  margin-bottom: 0;
  color: #726969;
}

.tcb-flags {
  text-align: center;
  margin: 1em auto 0.25em;
  display: flex;
  align-content: center;
  justify-content: center;
}

.flag {
  width: 8px;
  height: 8px;
  display: inline-block;
  position: relative;
  overflow: hidden;
  padding: 4px;
  margin: 2px;
  border: 1px solid #eee;
}

.flag::before,
.flag::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border: 0;
}

.c {
  background: #152536;
}

.c::before {
  top: 20%;
  bottom: 20%;
  background: #faf7f4;
}

.c::after {
  top: 40%;
  bottom: 40%;
  background: #f2916b;
}

.o {
  background: #f2916b;
}

.o::before {
  background: #ffe882;
  right: 35%;
  bottom: -100%;
  transform: rotate(-45deg);
  left: -100%;
}

.k {
  background: #ffe882;
}

.k::before {
  background: #152536;
  left: 50%;
}

.status {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.stat {
  background: var(--panel);
  padding: 14px 18px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  min-width: 150px;
}

.stat .label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat .value {
  font-weight: 700;
  font-size: 20px;
}

.game {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 28px;
}

.play-area {
  background: transparent;
  padding: 0 0 12px;
  border-radius: 20px;
  box-shadow: none;
  display: grid;
  gap: 12px;
  justify-items: center;
}

.letter-bank {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  width: 100%;
  margin-bottom: 12px;
}

.letter-tile {
  border: none;
  border-radius: 8px;
  background: var(--bg-accent);
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
  padding: 12px 0;
  min-width: 48px;
  min-height: 48px;
  max-width: 48px;
  max-height: 48px;
  cursor: grab;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.letter-tile:active {
  cursor: grabbing;
}

.letter-tile.used {
  opacity: 0.35;
  cursor: not-allowed;
}

.word-grid {
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
}

.word-grid:focus {
  outline: none;
}

.word-row {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.slot {
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 48px;
  max-height: 48px;
  max-width: 48px;
  border-radius: 4px;
  border: 2px solid #e2d6c5;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 700;
  font-family: 'Libre Franklin', system-ui, sans-serif;
  background: #fefefe;
  cursor: pointer;
  transition: border 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.slot.active {
  border-color: var(--accent);
  box-shadow: 0 8px 18px rgba(196, 95, 42, 0.2);
}

.controls {
  margin-top: 18px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

button.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.1rem;
  cursor: pointer;
  font-family: 'interstate-mono';
  text-transform: uppercase;
}

button.primary:hover {
  background: var(--accent-dark);
}

button.ghost {
  background: transparent;
  border: 1px solid #d7c6b3;
  border-radius: 8px;
  padding: 12px 20px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'interstate-mono';
  letter-spacing: 0.1rem;
  text-transform: uppercase;
  color: #152536;
}

.timer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
}

.timer-value {
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
}

.next-puzzle {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(29, 27, 22, 0.6);
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--panel);
  padding: 28px;
  border-radius: 18px;
  box-shadow: var(--shadow);
  text-align: center;
  max-width: 360px;
}

.modal-card h2 {
  margin: 6px 0 10px;
  font-size: 48px;
  font-family: 'matrix-ii-ext-semi-narrow';
  font-weight: 500;
  letter-spacing: -0.05rem;
}

.modal-eyebrow {
  text-transform: uppercase;
  font-family: 'interstate-mono', monospace;
  font-weight: 400;
  font-size: 12px;
  margin-top: 0.75em;
  color: #726969;
}

.message {
  margin-top: 12px;
  font-weight: 600;
}

.message.success {
  color: var(--success);
}

.message.error {
  color: var(--danger);
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.footer-countdown {
  display: none;
  margin: 0 0 6px;
  font-weight: 600;
}

.modal-time {
  margin: 12px 0 18px;
  font-weight: 300;
  color: var(--muted);
}

@media (max-width: 720px) {
  .page {
    padding: 0 16px 24px;
  }
  .flag {
    width: 16px;
    height: 16px;
  }
  .slot {
    min-height: 46px;
  }
}

@media (min-width: 40em) {
  .tcb-flags {
    text-align: center;
    margin: 1em auto 0.25em;
    display: flex;
    align-content: center;
    justify-content: center;
  }

  .flag {
    width: 14px;
    height: 14px;
    display: inline-block;
    position: relative;
    overflow: hidden;
    padding: 4px;
    margin: 2px;
    border: 1px solid #eee;
  }
}
