:root {
  --blue: #35479B;
  --blue-dark: #2a3a85;
  --blue-tint: #e8eaf5;
  --green: #70BF44;
  --green-dark: #5da336;
  --green-tint: #e9f6df;
  --red: #EC1D25;
  --red-dark: #c8141b;
  --ink: #1d2433;
  --bg: #f7f8fb;
  --cell: 36px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  overflow-x: hidden;
}

/* ---------- header ---------- */
.top-bar {
  background: var(--blue);
  color: #fff;
}

.top-bar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  display: grid;
  grid-template-columns: 11px 11px;
  gap: 3px;
}
.brand-mark span {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: #fff;
}
.brand-mark span:nth-child(2) { background: var(--green); }
.brand-mark span:nth-child(3) { background: var(--red); }

.brand-title {
  font-family: "Montserrat", sans-serif;
  font-weight: 800;
  font-size: 24px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0;
}

.timer-pill {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 14px;
}
.timer-pill strong {
  margin-left: 8px;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
}

/* ---------- layout ---------- */
.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 24px;
  align-items: start;
}

/* ---------- board ---------- */
.clue-bar {
  display: flex;
  align-items: center;
  background: var(--green);
  border-radius: 12px;
  min-height: 52px;
  padding: 0 8px;
  margin-bottom: 16px;
  box-shadow: 0 4px 14px rgba(112, 191, 68, 0.35);
}

.clue-bar-btn {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  color: #fff;
  cursor: pointer;
  flex: 0 0 auto;
}
.clue-bar-btn:hover { background: rgba(255, 255, 255, 0.32); }

.clue-bar-text {
  flex: 1;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  padding: 8px 10px;
}

.grid-card {
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(53, 71, 155, 0.12);
  display: flex;
  justify-content: center;
  overflow: hidden;
  min-width: 0;
}

.board-col, .clues-col, .phrase-card { min-width: 0; }

.grid {
  display: grid;
  background: var(--blue);
  border-radius: 10px;
  padding: 12px;
  gap: 2px;
  outline: none;
  touch-action: manipulation;
}

.cell {
  width: var(--cell);
  height: var(--cell);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.cell.block { background: transparent; }

.cell.letter {
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 700;
  font-size: calc(var(--cell) * 0.5);
  color: var(--ink);
}

.cell.letter.in-word { background: var(--green-tint); box-shadow: inset 0 0 0 2px var(--green); }
.cell.letter.focus {
  background: #d3eebb;
  box-shadow: inset 0 0 0 3px var(--green-dark);
}
.cell.letter.wrong { color: var(--red); }

.cell-num {
  position: absolute;
  top: 1px;
  left: 2px;
  font-size: max(7px, calc(var(--cell) * 0.25));
  font-weight: 700;
  color: var(--blue);
}

.cell-circle {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: calc(var(--cell) * 0.25);
  height: calc(var(--cell) * 0.25);
  border: 1.5px solid var(--red);
  border-radius: 50%;
}

/* ---------- clue cards ---------- */
.clue-card {
  background: #fff;
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 20px;
  box-shadow: 0 10px 30px rgba(53, 71, 155, 0.12);
  border-top: 5px solid var(--green);
}
.clue-card-down { border-top-color: var(--red); }

.clue-card-title {
  font-family: "Montserrat", sans-serif;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--green-dark);
  margin: 4px 0 12px;
}
.clue-card-down .clue-card-title { color: var(--red-dark); }

.clue-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.clue-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13.5px;
  line-height: 1.4;
}

.clue-item:hover { background: var(--blue-tint); }
.clue-item.active { background: var(--blue); color: #fff; }
.clue-item.active .clue-num { background: #fff; color: var(--blue); }
.clue-item.solved .clue-text { color: #9aa39a; text-decoration: line-through; }
.clue-item.active.solved .clue-text { color: #cdd4ee; }

.clue-num {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--blue-tint);
  color: var(--blue);
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.clue-card-across .clue-num { background: var(--green-tint); color: var(--green-dark); }
.clue-card-down .clue-num { background: #fde3e4; color: var(--red-dark); }
.clue-card-across .clue-item.active .clue-num { background: #fff; color: var(--green-dark); }
.clue-card-down .clue-item.active .clue-num { background: #fff; color: var(--red-dark); }

/* ---------- phrase ---------- */
.phrase-card {
  grid-column: 1 / -1;
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(53, 71, 155, 0.12);
  border-top: 5px solid var(--blue);
}

.phrase-title {
  font-family: "Montserrat", sans-serif;
  font-weight: 800;
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--blue);
  margin: 0 0 22px;
}

.phrase-slots {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.phrase-slot {
  width: 42px;
  height: 46px;
  border: 2px solid var(--blue-tint);
  border-bottom: 4px solid var(--red);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Montserrat", sans-serif;
  font-weight: 800;
  font-size: 22px;
  color: var(--red);
  background: var(--bg);
}

.phrase-hint { font-size: 12.5px; color: #8a90a3; margin: 0; }

/* ---------- day navigation ---------- */
.nav-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
}

.nav-btn {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-family: "Inter", sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.nav-btn:hover:not(:disabled) { background: var(--blue-dark); }
.nav-btn:disabled { background: #c3c8de; cursor: default; }

.nav-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--blue);
  min-width: 170px;
  text-align: center;
}

/* ---------- win overlay ---------- */
.win-overlay {
  position: fixed;
  inset: 0;
  background: rgba(29, 36, 51, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.win-overlay.hidden { display: none; }

.win-modal {
  background: #fff;
  border-radius: 18px;
  border-top: 6px solid var(--green);
  padding: 36px 48px;
  text-align: center;
  max-width: 440px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
}

.win-modal h2 {
  font-family: "Montserrat", sans-serif;
  font-weight: 800;
  font-size: 28px;
  color: var(--blue);
  margin: 0 0 14px;
}

.win-phrase-label { color: #8a90a3; margin-bottom: 4px; }

.win-phrase {
  font-family: "Montserrat", sans-serif;
  font-weight: 800;
  font-size: 26px;
  letter-spacing: 0.25em;
  color: var(--red);
  margin: 4px 0 22px;
}

.win-btn {
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 13px 30px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.win-btn:hover { background: var(--green-dark); }

#mobileInput {
  position: fixed;
  opacity: 0;
  pointer-events: none;
  left: -9999px;
  top: 0;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.grid.shake { animation: shake 0.3s ease 2; }

@media (max-width: 960px) {
  .page { padding: 14px 10px 32px; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }

  .top-bar-inner { padding: 12px 14px; }
  .brand-title { font-size: 18px; letter-spacing: 0.04em; }
  .brand-mark { grid-template-columns: 9px 9px; }
  .brand-mark span { width: 9px; height: 9px; }
  .timer-pill { padding: 6px 12px; font-size: 12px; white-space: nowrap; }
  .timer-pill strong { font-size: 13px; }

  .clue-bar { min-height: 46px; border-radius: 10px; margin-bottom: 12px; }
  .clue-bar-btn { width: 32px; height: 32px; font-size: 19px; }
  .clue-bar-text { font-size: 13px; padding: 7px 6px; }

  .grid-card { padding: 8px; border-radius: 12px; }
  .grid { padding: 8px; border-radius: 8px; }

  .clue-card { padding: 12px 12px; border-radius: 12px; margin-bottom: 14px; }
  .clue-item { font-size: 13px; padding: 7px 6px; }

  .phrase-card { padding: 20px 10px 16px; border-radius: 12px; }
  .phrase-title { font-size: 15px; margin-bottom: 16px; }
  .phrase-slots { gap: 6px; margin-bottom: 12px; }
  .phrase-slot { width: 32px; height: 38px; font-size: 17px; border-radius: 6px; }
  .phrase-hint { font-size: 11.5px; }

  .nav-row { gap: 8px; flex-wrap: wrap; }
  .nav-btn { padding: 9px 14px; font-size: 12.5px; }
  .nav-label { min-width: 0; font-size: 12.5px; order: -1; width: 100%; }

  .win-modal { margin: 0 14px; padding: 26px 22px; }
  .win-modal h2 { font-size: 23px; }
  .win-phrase { font-size: 21px; letter-spacing: 0.18em; }
}
