@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@600;700&display=swap");

:root {
  --bg: #08090c;
  --bg-deep: #11131a;
  --surface: rgba(22, 25, 33, 0.88);
  --surface-strong: rgba(29, 33, 45, 0.98);
  --ink: #f4efdf;
  --ink-soft: #b8b6b0;
  --accent: #e4ab49;
  --accent-strong: #ffcb7f;
  --selected: #ffcb7f;
  --found: #6bd39a;
  --auto: #9da6b6;
  --shadow: 0 20px 50px rgba(4, 6, 10, 0.55);
  --board-size: min(70vw, 42rem);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding-top: max(env(safe-area-inset-top), 0px);
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: hidden;
  color: var(--ink);
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.06), transparent 34%),
    radial-gradient(circle at bottom right, rgba(255, 206, 128, 0.2), transparent 34%),
    linear-gradient(135deg, #060709, var(--bg) 45%, var(--bg-deep));
}

button,
select {
  font: inherit;
  color-scheme: dark;
}

.page-shell {
  width: min(1280px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 2rem;
}

.hero {
  display: flex;
  justify-content: flex-start;
  gap: 1.5rem;
  align-items: start;
  margin-bottom: 1.5rem;
}

.hero > div:first-child {
  width: min(70vw, 42rem);
  max-width: 100%;
  margin: 0 auto;
  text-align: center;
}

.eyebrow,
.panel-label {
  margin: 0 0 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: var(--ink-soft);
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

h1 {
  font-family: "Cormorant Garamond", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-weight: 700;
  letter-spacing: 0.01em;
  font-size: clamp(2.2rem, 4.8vw, 4.15rem);
  line-height: 0.95;
  white-space: nowrap;
}

.subtitle {
  width: 100%;
  margin: 0.75rem 0 0;
  color: var(--ink-soft);
}

#verse-progress,
#verse-progress .verse-word {
  -webkit-user-select: none;
  user-select: none;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 0.75rem;
  width: min(100%, 390px);
}

.stat-card,
.card,
.board-panel {
  border: 1px solid rgba(95, 62, 32, 0.14);
  border-radius: 24px;
  background: var(--surface);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 1rem 1.1rem;
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-bottom: 0.4rem;
}

.stat-card strong {
  font-size: 1.7rem;
  font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.95fr);
  gap: 1.25rem;
}

.board-panel {
  padding: 1rem;
}

.board-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
}

.board-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  align-items: center;
}

.test-tools {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  background: rgba(14, 18, 26, 0.9);
  padding: 0.45rem 0.55rem 0.55rem;
}

.test-tools summary {
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--ink-soft);
  list-style: none;
}

.test-tools summary::-webkit-details-marker {
  display: none;
}

.test-actions {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: end;
}

.test-date-wrap {
  min-width: 150px;
}

.test-tools-card {
  padding: 0.8rem 0.95rem;
}

.test-tools-card .test-tools {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

.test-date-wrap input {
  appearance: none;
  -webkit-appearance: none;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(18, 22, 31, 0.95);
  color: #f4efdf;
  padding: 0.65rem 0.9rem;
  font: inherit;
  color-scheme: dark;
}

#difficulty-control,
#verse-control {
  display: none !important;
}

.select-wrap {
  display: grid;
  gap: 0.25rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(18, 22, 31, 0.95);
  padding: 0.65rem 0.9rem;
  color: #f4efdf;
}

.select-wrap select:focus-visible {
  outline: 2px solid rgba(255, 203, 127, 0.9);
  outline-offset: 2px;
}

.select-wrap select option {
  background: #10131b;
  color: #f4efdf;
}

.button {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(255, 203, 127, 0.45);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 183, 77, 0.23), rgba(255, 203, 127, 0.14));
  color: #ffe5bf;
  padding: 0.72rem 1.05rem;
  cursor: pointer;
}

.button.ghost {
  color: #f3ede1;
  background: rgba(22, 26, 37, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.24);
}

.button:hover {
  background: linear-gradient(135deg, rgba(255, 183, 77, 0.33), rgba(255, 203, 127, 0.2));
}

.button.ghost:hover {
  background: rgba(30, 36, 50, 0.98);
}

.select-wrap select:disabled,
.button:disabled {
  opacity: 1;
  cursor: not-allowed;
}

.select-wrap select:disabled {
  background: rgba(14, 17, 24, 0.94);
  color: rgba(244, 239, 223, 0.86);
  border-color: rgba(255, 255, 255, 0.16);
}

.button:disabled {
  background: rgba(31, 36, 49, 0.92);
  color: rgba(255, 229, 191, 0.82);
  border-color: rgba(255, 203, 127, 0.28);
}

.selection-status {
  margin: 1rem 0 0.85rem;
  min-height: 1.5rem;
  color: var(--ink-soft);
}

.daily-return-message {
  margin: 1rem 0 0.85rem;
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(18, 22, 31, 0.62);
  color: rgba(244, 239, 223, 0.9);
  font-size: 0.95rem;
}

.completion-confetti {
  position: fixed;
  z-index: 80;
  pointer-events: none;
  will-change: transform, opacity;
  border-radius: 999px;
  box-shadow: 0 0 12px rgba(255, 210, 132, 0.75);
}

.timer-penalty-pop {
  position: fixed;
  z-index: 90;
  pointer-events: none;
  color: #ff6c6c;
  font-weight: 900;
  font-size: 4.1rem;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.52);
}

.solitaire-tile {
  position: fixed;
  z-index: 85;
  pointer-events: none;
  display: inline-block;
  text-align: center;
  border-radius: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  will-change: transform, opacity;
  font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-weight: 700;
}

.grid-wrapper {
  position: relative;
  display: flex;
  justify-content: center;
  padding: 0.75rem;
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(35, 39, 50, 0.88), rgba(22, 25, 33, 0.92)),
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent 20px,
      rgba(255, 255, 255, 0.03) 20px,
      rgba(255, 255, 255, 0.03) 21px
    );
}

.grid {
  display: grid;
  position: relative;
  z-index: 2;
  --grid-size: 15;
  --selection-color: hsla(42, 60%, 40%, 1);
  width: 100%;
  max-width: var(--board-size);
  aspect-ratio: 1 / 1;
  gap: 0.18rem;
  touch-action: none;
  user-select: none;
}

.cell {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  margin: 0;
  border-radius: 12px;
  background: rgba(14, 18, 26, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f4efdf;
  font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-weight: 700;
  font-size: clamp(0.82rem, calc(var(--board-size) / (var(--grid-size) * 2.15)), 2rem);
  text-transform: uppercase;
  transition: transform 120ms ease, background-color 120ms ease, color 120ms ease;
}

.cell.selected {
  background: var(--selection-color);
  color: #ffe8c4;
  border-color: rgba(0, 0, 0, 0.22);
  transform: translateY(-1px);
}

.cell.found {
  color: #f4efdf;
}

.found-link-layer {
  position: absolute;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.selection-link-layer {
  position: absolute;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.found-link-stroke {
  position: absolute;
  border-radius: 999px;
}

.cell.just-found {
  animation: found-pop 1240ms cubic-bezier(0.2, 0.75, 0.2, 1);
}

.side-panel {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.card {
  padding: 1rem;
}

.verse-progress {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.7;
}

.verse-word {
  display: inline-block;
  margin-right: 0.18rem;
  border-bottom: 2px solid transparent;
}

.verse-word.hidden {
  min-width: 3ch;
  color: transparent;
  border-bottom-color: rgba(224, 220, 206, 0.72);
  background: linear-gradient(90deg, rgba(95, 62, 32, 0.18), rgba(95, 62, 32, 0.08));
  border-radius: 0.2rem;
}

.verse-word.hidden.hinted {
  color: rgba(95, 62, 32, 0.45);
}

.verse-word.visible {
  color: var(--ink);
  border-bottom-color: rgba(93, 123, 73, 0.3);
}

.word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  min-height: 1.5rem;
}

.word-chip {
  padding: 0.45rem 0.72rem;
  border-radius: 999px;
  background: rgba(255, 249, 238, 0.9);
  border: 1px solid rgba(95, 62, 32, 0.12);
  font-size: 0.92rem;
}

.word-chip.found {
  color: #f4efdf;
}

.word-chip.auto {
  background: rgba(125, 105, 85, 0.15);
  border-color: rgba(125, 105, 85, 0.35);
}

.reading-room {
  display: grid;
  gap: 0.9rem;
  max-height: 28rem;
  overflow: auto;
  padding-right: 0.2rem;
}

.reading-entry {
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(95, 62, 32, 0.12);
}

.reading-entry:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.reading-entry p,
.empty-copy {
  margin: 0.35rem 0 0;
  color: var(--ink-soft);
  line-height: 1.5;
}

.reading-all-link {
  color: #ffe5bf;
  text-decoration: underline;
  text-underline-offset: 0.18rem;
  font-size: 0.95rem;
}

.locked-placeholder::before {
  content: "\1F512";
  margin-right: 0.35rem;
}

@media (prefers-color-scheme: dark) {
  .cell.found,
  .word-chip.found {
  color: #f4efdf;
  }
}

.fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.flying-letter {
  position: fixed;
  left: 0;
  top: 0;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 0.55rem;
  display: grid;
  place-items: center;
  font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: #1b1b1b;
  background: rgba(253, 231, 197, 0.96);
  border: 1px solid rgba(95, 62, 32, 0.26);
  box-shadow: 0 9px 24px rgba(38, 27, 11, 0.18);
  transform: translate(-50%, -50%);
}

@keyframes found-pop {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  35% {
    transform: scale(1.18) translateY(-2px);
    filter: brightness(1.1);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

@media (max-width: 960px) {
  .hero,
  .board-toolbar {
    flex-direction: column;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  :root {
    --board-size: min(calc(100vw - 4rem), 34rem);
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 0.4rem, 1280px);
    padding-top: 0.2rem;
    overflow-x: clip;
  }

  .hero > div {
    width: 100%;
    text-align: center;
  }

  h1 {
    font-size: clamp(1.4rem, 7.6vw, 2.2rem);
  }


  .eyebrow {
    display: none;
  }

  .subtitle,
  .selection-status {
    display: none;
  }

  .hero-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    gap: 0.35rem;
  }

  .stat-card {
    border-radius: 14px;
    min-height: 2rem;
    padding: 0.28rem 0.5rem;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 0.25rem;
  }

  .stat-label {
    font-size: 0.66rem;
    margin-bottom: 0;
    line-height: 1;
  }

  .stat-card strong {
    font-size: 0.9rem;
    line-height: 1;
  }

  .board-panel,
  .card {
    border-radius: 20px;
  }

  .board-panel,
  .card {
    padding: 0.62rem;
  }

  .board-toolbar {
    gap: 0.7rem;
  }

  .board-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
  }

  .select-wrap {
    font-size: 0.78rem;
  }

  .select-wrap select {
    padding: 0.5rem 0.72rem;
  }

  .button {
    width: 100%;
    padding: 0.42rem 0.62rem;
    font-size: 0.78rem;
  }

  .grid-wrapper {
    padding: 0.08rem;
    overflow: hidden;
  }

  .grid {
    gap: 0.1rem;
  }

  .cell {
    border-radius: 10px;
    font-size: clamp(0.88rem, calc(var(--board-size) / (var(--grid-size) * 2.1)), 1.6rem);
  }

  #words-card {
    display: none;
  }

  :root {
    --board-size: min(calc(100vw - 1.4rem), 24rem);
  }
}
