﻿html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

* {
  box-sizing: border-box;
}

:root {
  --sl-bg-warm: #f6f0e6;
  --sl-parchment: #efe3d3;
  --sl-ink: #2e3a4d;
  --sl-muted: #6b7280;
  --sl-gold: #e6b24a;
  --sl-gold-2: #f2d27a;
  --sl-accent: #4f7dff;
  --sl-success: #2ecc71;
  --sl-shadow: rgba(16, 24, 40, 0.12);
  --radius-card: 18px;
  --radius-btn: 16px;
  --soft-border: 1px solid rgba(46, 58, 77, 0.08);
  --soft-shadow: 0 10px 30px rgba(16, 24, 40, 0.1);
  --bg-start-image: none;
  --bg-game-image: none;
  --font-brand: "Fraunces", Georgia, "Times New Roman", serif;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

body {
  font-family: var(--font-ui);
  color: var(--sl-ink);
  touch-action: none;
  position: relative;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.55), transparent 48%),
    radial-gradient(circle at 80% 75%, rgba(242, 210, 122, 0.26), transparent 42%),
    linear-gradient(150deg, var(--sl-bg-warm) 0%, #f0e4d5 50%, #eadcc9 100%);
}

.start-screen,
.game-screen,
.modal {
  position: relative;
  z-index: 1;
}

.start-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(18px, 3vw, 32px);
  background:
    linear-gradient(150deg, rgba(246, 240, 230, 0.45), rgba(239, 227, 211, 0.38)),
    var(--bg-start-image);
  background-size: cover;
  background-position: center;
}

.scene-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 78%, rgba(255, 255, 255, 0.44), transparent 36%),
    radial-gradient(circle at 74% 22%, rgba(242, 210, 122, 0.2), transparent 42%);
}

.start-content {
  position: relative;
  z-index: 1;
  width: min(94vw, 900px);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.game-logo {
  width: min(78vw, 460px);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 8px 16px rgba(16, 24, 40, 0.12));
}

.brand-title {
  margin: 0;
  font-family: var(--font-brand);
  font-size: clamp(42px, 7vw, 88px);
  line-height: 1;
  color: var(--sl-ink);
}

.start-copy {
  margin: 0;
  font-size: clamp(17px, 1.8vw, 26px);
  font-weight: 500;
  color: var(--sl-muted);
}

.btn {
  border: 0;
  cursor: pointer;
  border-radius: var(--radius-btn);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  font-family: var(--font-ui);
}

.btn:hover,
.icon-btn:hover {
  transform: translateY(-1px);
}

.btn:active,
.icon-btn:active {
  transform: translateY(1px);
}

.btn-primary {
  min-width: clamp(230px, 24vw, 340px);
  padding: 16px 28px;
  font-size: clamp(22px, 2.2vw, 32px);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #5c3b0a;
  background: linear-gradient(180deg, #f7dd97 0%, var(--sl-gold-2) 42%, var(--sl-gold) 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.52),
    0 10px 24px rgba(191, 133, 27, 0.26),
    0 0 20px rgba(242, 210, 122, 0.22);
}

.btn-secondary {
  min-width: 170px;
  padding: 13px 20px;
  font-size: 16px;
  font-weight: 600;
  color: var(--sl-ink);
  background: rgba(255, 255, 255, 0.9);
  border: var(--soft-border);
  box-shadow: 0 8px 18px rgba(16, 24, 40, 0.08);
}

.icon-btn {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  border: var(--soft-border);
  background: rgba(255, 255, 255, 0.86);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--soft-shadow);
  cursor: pointer;
}

.icon-btn[aria-pressed="false"] {
  opacity: 0.82;
}

.icon-glyph {
  font-size: 24px;
  line-height: 1;
}

.sound-toggle {
  position: absolute;
  top: clamp(14px, 2.4vw, 24px);
  right: clamp(14px, 2.4vw, 24px);
  z-index: 2;
}

.game-screen {
  display: none;
  width: 100%;
  height: 100%;
  padding: clamp(12px, 1.8vw, 24px);
  grid-template-rows: auto 1fr auto;
  gap: clamp(10px, 1.2vw, 16px);
  background:
    linear-gradient(160deg, rgba(246, 240, 230, 0.4), rgba(236, 223, 203, 0.34)),
    var(--bg-game-image);
  background-size: cover;
  background-position: center;
}

.game-screen.is-visible {
  display: grid;
}

.game-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.game-title {
  font-family: var(--font-brand);
  font-size: clamp(24px, 2.1vw, 34px);
  color: rgba(46, 58, 77, 0.9);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-actions .sound-toggle {
  position: static;
}

.score-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 54px;
  padding: 0 14px;
  border-radius: 16px;
  border: var(--soft-border);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--soft-shadow);
  font-size: 16px;
  color: var(--sl-muted);
}

.score-pill strong {
  font-size: clamp(24px, 2.1vw, 34px);
  line-height: 1;
  color: var(--sl-ink);
}

.game-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: clamp(12px, 1.8vw, 20px);
}

.panel {
  border-radius: var(--radius-card);
  border: var(--soft-border);
  box-shadow: var(--soft-shadow);
  background: rgba(255, 253, 249, 0.92);
}

.words-card {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: clamp(14px, 1.4vw, 18px);
  background:
    linear-gradient(160deg, rgba(239, 227, 211, 0.95), rgba(248, 241, 233, 0.93));
}

.words-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.words-head h2 {
  margin: 0;
  font-family: var(--font-brand);
  font-size: clamp(24px, 2vw, 32px);
  color: var(--sl-ink);
}

.time-chip {
  font-size: 14px;
  font-weight: 600;
  color: var(--sl-muted);
  padding: 6px 12px;
  border-radius: 999px;
  border: var(--soft-border);
  background: rgba(255, 255, 255, 0.74);
}

.word-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  min-height: 0;
}

.word-item {
  font-size: clamp(20px, 1.45vw, 28px);
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: rgba(46, 58, 77, 0.92);
  padding: clamp(8px, 1vw, 12px) 0;
  border-bottom: 1px solid rgba(46, 58, 77, 0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.word-item.found {
  color: rgba(46, 58, 77, 0.55);
  font-size: clamp(18px, 1.25vw, 24px);
}

.word-item.found::before {
  content: "\2713";
  color: var(--sl-success);
  font-weight: 700;
}

.board-card {
  min-height: 0;
  padding: clamp(10px, 1.2vw, 14px);
  background: rgba(255, 255, 255, 0.78);
}

.board {
  width: 100%;
  height: 100%;
  display: grid;
  gap: 4px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.cell {
  border: 1px solid rgba(46, 58, 77, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--sl-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(14px, 2vw, 34px);
  font-weight: 700;
  text-transform: uppercase;
}

.cell.selected {
  background: rgba(79, 125, 255, 0.16);
  border-color: rgba(79, 125, 255, 0.42);
}

.cell.found {
  background: rgba(46, 204, 113, 0.22);
  border-color: rgba(46, 204, 113, 0.5);
  box-shadow: inset 0 0 0 1px rgba(46, 204, 113, 0.28);
}

.game-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.audio-hint,
.status-text {
  margin: 0;
  min-height: 18px;
  font-size: 14px;
  color: var(--sl-muted);
}

.status-text {
  text-align: right;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.is-open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 24, 37, 0.28);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  width: min(520px, 100%);
  border-radius: 20px;
  border: 1px solid rgba(230, 178, 74, 0.6);
  background: linear-gradient(165deg, rgba(251, 245, 236, 0.98), rgba(242, 231, 215, 0.98));
  box-shadow:
    0 14px 34px rgba(16, 24, 40, 0.18),
    0 0 24px rgba(230, 178, 74, 0.2);
  text-align: center;
  padding: clamp(22px, 2.7vw, 30px);
}

.modal-card h3 {
  margin: 0;
  font-family: var(--font-brand);
  font-size: clamp(36px, 3.4vw, 48px);
  color: #75481b;
}

.modal-card p {
  margin: 12px 0 0;
  color: var(--sl-ink);
  font-size: clamp(18px, 1.7vw, 24px);
}

.finish-score {
  font-weight: 700;
  color: #6e4a14;
}

.modal-actions {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 960px) {
  .game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .words-card {
    max-height: 30vh;
  }

  .board-card {
    min-height: 52vh;
  }

  .word-item {
    font-size: clamp(18px, 4.8vw, 24px);
  }
}

@media (max-width: 640px) {
  .start-copy {
    font-size: clamp(16px, 4.7vw, 22px);
  }

  .btn-primary {
    min-width: 80vw;
    padding: 14px 24px;
    font-size: clamp(20px, 6vw, 28px);
  }

  .icon-btn {
    width: 50px;
    height: 50px;
  }

  .game-screen {
    padding: 10px;
  }

  .game-title {
    font-size: 22px;
  }

  .score-pill {
    min-height: 48px;
    padding: 0 10px;
    gap: 6px;
  }

  .score-pill strong {
    font-size: 24px;
  }

  .cell {
    font-size: clamp(13px, 4.5vw, 20px);
  }

  .modal-actions {
    flex-direction: column;
  }

  .btn-secondary,
  .modal-actions .btn-primary {
    width: 100%;
  }
}


