:root {
  color-scheme: dark;
  --bg-a: #4f1718;
  --bg-b: #270d0d;
  --panel: rgba(82, 25, 24, 0.72);
  --panel-strong: rgba(120, 43, 36, 0.82);
  --line: rgba(253, 230, 180, 0.28);
  --text: #fff8ec;
  --muted: #f4d9b3;
  --shadow: 0 18px 48px rgba(30, 6, 5, 0.38);
  --accent-a: #8f2f27;
  --accent-b: #e7b35d;
  --cw-cell-size: 42px;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background:
    linear-gradient(rgba(68, 18, 18, 0.42), rgba(42, 12, 12, 0.72)),
    url("assets/batik-bg.jpeg") center top / 420px auto repeat,
    #6f2422;
  color: var(--text);
}

button {
  font: inherit;
}

button,
input {
  font: inherit;
}

.screen {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px clamp(14px, 3vw, 28px);
}

.wide-screen {
  width: min(1360px, 100%);
}

.hero {
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
  padding: 12px 0 24px;
}

.compact-hero {
  padding-top: 0;
}

.logo {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: linear-gradient(135deg, #7b2420, #b85a37 48%, #e7b35d);
  box-shadow: var(--shadow);
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 0;
}

.main-logo {
  width: clamp(116px, 18vw, 190px);
  height: clamp(116px, 18vw, 190px);
  object-fit: contain;
  filter: drop-shadow(0 18px 30px rgba(34, 8, 7, 0.34));
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1.02;
  font-weight: 900;
}

.gradient-text {
  display: block;
  background: linear-gradient(90deg, #ffe3a3, #e7b35d, #c76a42);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.title-plain {
  display: block;
  color: var(--text);
}

.subtitle {
  max-width: 46rem;
  color: var(--muted);
  font-size: clamp(0.95rem, 2vw, 1.08rem);
  line-height: 1.6;
}

.section-label {
  margin: 8px 4px 12px;
  color: #f6d79b;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

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

.game-tile {
  min-height: 180px;
  border: 1px solid rgba(255, 232, 187, 0.22);
  border-radius: 20px;
  display: grid;
  grid-template-columns: 72px 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 22px;
  color: white;
  text-align: left;
  background: rgba(93, 28, 26, 0.72);
  box-shadow: var(--shadow);
  transition:
    transform 0.18s ease,
    border-color 0.18s ease;
}

.game-tile:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 232, 187, 0.48);
}

.tile-warm {
  background: linear-gradient(135deg, rgba(131, 42, 31, 0.92), rgba(224, 160, 77, 0.48));
}

.tile-cool {
  background: linear-gradient(135deg, rgba(102, 35, 31, 0.92), rgba(191, 107, 65, 0.48));
}

.tile-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.2);
  font-size: 1.35rem;
  font-weight: 900;
}

.tile-copy {
  display: grid;
  gap: 8px;
}

.tile-copy strong {
  font-size: clamp(1.2rem, 2vw, 1.75rem);
  line-height: 1.1;
}

.tile-copy small {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.95rem;
  line-height: 1.5;
}

.tile-action {
  min-width: 64px;
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.2);
  text-align: center;
  font-weight: 900;
}

.level-list {
  display: grid;
  gap: 12px;
}

.level-card {
  width: 100%;
  min-height: 92px;
  border: 1px solid rgba(255, 232, 187, 0.2);
  border-radius: 16px;
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 16px;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.13);
  text-align: left;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease;
}

.level-card:not(:disabled):hover {
  transform: translateY(-2px);
  border-color: rgba(255, 232, 187, 0.44);
}

.level-card:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.level-card.active {
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
  border-color: rgba(255, 238, 198, 0.72);
}

.level-no {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.2);
  font-size: 1.25rem;
  font-weight: 900;
}

.level-title {
  font-weight: 900;
}

.level-meta {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.82rem;
}

.level-action {
  min-width: 42px;
  height: 42px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.2);
  font-weight: 900;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 232, 187, 0.2);
  border-radius: 12px;
  color: white;
  background: rgba(82, 25, 24, 0.64);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.pill {
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(70, 19, 18, 0.58);
  color: #ffe8bc;
  font-size: 0.82rem;
  font-weight: 800;
}

.game-title {
  margin-bottom: 16px;
}

.game-title h2 {
  font-size: clamp(1.45rem, 3vw, 2.25rem);
  font-weight: 900;
}

.game-title p {
  color: var(--muted);
}

.progress {
  height: 10px;
  margin: 14px 0 18px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
}

.progress > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
  transition: width 0.25s ease;
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(18px, 6vw, 140px);
  padding: clamp(12px, 2vw, 22px);
  border: 1px solid rgba(255, 232, 187, 0.2);
  border-radius: 18px;
  background: rgba(71, 20, 20, 0.66);
  box-shadow: var(--shadow);
}

.column {
  display: grid;
  gap: 10px;
}

.card {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 58px;
  border: 1px solid rgba(255, 232, 187, 0.2);
  border-radius: 14px;
  padding: 14px 16px;
  color: white;
  background: rgba(112, 39, 33, 0.78);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.13);
  font-weight: 900;
  text-align: center;
  transition:
    transform 0.15s ease,
    background 0.15s ease,
    border-color 0.15s ease,
    opacity 0.15s ease;
}

.card:not(:disabled):hover,
.card.selected {
  transform: translateY(-1px);
  border-color: rgba(255, 232, 187, 0.72);
  background: rgba(139, 51, 39, 0.84);
}

.card.matched {
  border-color: rgba(255, 255, 255, 0.42);
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
}

.card.wrong {
  animation: shake 0.24s ease;
  border-color: #fca5a5;
  background: rgba(239, 68, 68, 0.28);
}

.card:disabled {
  cursor: default;
}

.lines {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.lines line {
  stroke: url(#lineGradient);
  stroke-width: 5;
  stroke-linecap: round;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.footer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.primary,
.secondary {
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  font-weight: 900;
}

.primary {
  color: white;
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
  box-shadow: 0 16px 36px rgba(249, 115, 22, 0.26);
}

.secondary {
  color: #ffe8bc;
  background: rgba(82, 25, 24, 0.64);
}

.small-button {
  min-height: 40px;
  padding: 0 14px;
}

.danger-button {
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  border: 0;
  border-radius: 12px;
  color: #fee2e2;
  background: rgba(239, 68, 68, 0.22);
  font-weight: 900;
}

.dialog {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(7, 10, 25, 0.72);
  backdrop-filter: blur(10px);
}

.dialog-card {
  width: min(420px, 100%);
  border: 1px solid rgba(255, 232, 187, 0.2);
  border-radius: 18px;
  padding: 24px;
  background: #ffffff;
  color: #182033;
  text-align: center;
  box-shadow: var(--shadow);
}

.dialog-card h2 {
  font-size: 1.75rem;
  font-weight: 900;
}

.dialog-card p {
  margin-top: 8px;
  color: #64748b;
}

.result-grid {
  display: grid;
  gap: 8px;
  margin: 18px 0;
  padding: 14px;
  border-radius: 14px;
  background: #f8fafc;
}

.result-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #475569;
}

.result-row strong {
  color: #111827;
}

.set-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  padding: 20px;
  background: rgba(82, 25, 24, 0.72);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.set-card h3 {
  font-size: 1.25rem;
  font-weight: 900;
}

.set-card p {
  margin: 6px 0;
  color: var(--muted);
}

.set-actions {
  display: grid;
  grid-template-columns: 110px 110px;
  gap: 8px;
}

.crossword-layout,
.builder-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.crossword-shell,
.builder-panel,
.preview-panel,
.clue-panel {
  border: 1px solid rgba(255, 232, 187, 0.2);
  border-radius: 18px;
  background: rgba(71, 20, 20, 0.72);
  box-shadow: var(--shadow);
}

.crossword-shell {
  overflow: auto;
  padding: 18px;
}

.crossword-grid {
  display: grid;
  gap: 4px;
  width: max-content;
}

.cw-cell {
  position: relative;
  width: var(--cw-cell-size);
  height: var(--cw-cell-size);
  border-radius: 6px;
  background: #fff2dc;
  color: #32100e;
  overflow: hidden;
}

.cw-cell.empty {
  background: transparent;
}

.cw-cell span {
  position: absolute;
  top: 3px;
  left: 4px;
  font-size: 0.62rem;
  font-weight: 900;
  color: #7c2d24;
  pointer-events: none;
}

.cw-cell input {
  width: 100%;
  height: 100%;
  border: 0;
  padding-top: 7px;
  color: #32100e;
  background: transparent;
  text-align: center;
  text-transform: uppercase;
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 900;
  outline: 2px solid transparent;
}

.cw-cell input:focus {
  outline-color: var(--accent-b);
}

.cw-wrong {
  background: #ffd7c2;
}

.clue-panel {
  padding: 16px;
  position: sticky;
  top: 14px;
}

.clue-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.notice {
  margin: 10px 0;
  border: 1px solid rgba(255, 232, 187, 0.18);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(92, 30, 25, 0.66);
  color: #fef3c7;
  font-weight: 800;
}

.clue-columns {
  display: grid;
  gap: 16px;
}

.clue-columns h3,
.preview-panel h3 {
  margin-bottom: 8px;
  font-size: 1rem;
  font-weight: 900;
}

.clue-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.clue-list button {
  width: 100%;
  border: 0;
  border-radius: 10px;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
  padding: 9px;
  color: white;
  background: rgba(255, 235, 195, 0.1);
  text-align: left;
}

.clue-list button:hover {
  background: rgba(255, 235, 195, 0.18);
}

.builder-layout {
  grid-template-columns: minmax(0, 1fr) 330px;
}

.builder-panel,
.preview-panel {
  padding: 16px;
}

.field-label {
  display: block;
  margin: 10px 0 6px;
  color: #ffe8bc;
  font-size: 0.82rem;
  font-weight: 900;
}

.text-field,
.question-row input {
  width: 100%;
  border: 1px solid rgba(255, 232, 187, 0.2);
  border-radius: 12px;
  padding: 11px 12px;
  color: white;
  background: rgba(70, 19, 18, 0.62);
  outline: 2px solid transparent;
}

.text-field:focus,
.question-row input:focus {
  outline-color: rgba(251, 191, 36, 0.72);
}

.builder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 10px;
}

.question-list {
  display: grid;
  gap: 8px;
}

.question-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1.4fr) minmax(120px, 0.8fr) 36px;
  gap: 8px;
  align-items: center;
}

.question-row > span {
  color: #f4d9b3;
  font-weight: 900;
  text-align: center;
}

.mini {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.mini-grid {
  display: grid;
  gap: 3px;
  overflow: auto;
  max-width: 100%;
}

.mini-grid span {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 3px;
  color: #32100e;
  background: #fff2dc;
  font-size: 0.62rem;
  font-weight: 900;
}

.mini-grid span.empty {
  background: rgba(255, 255, 255, 0.05);
}

.preview-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

@keyframes shake {
  33% {
    transform: translateX(-5px);
  }
  66% {
    transform: translateX(5px);
  }
}

@media (max-width: 700px) {
  :root {
    --cw-cell-size: 34px;
  }

  .screen {
    padding-bottom: 18px;
  }

  .hero {
    padding-top: 4px;
  }

  .level-card {
    grid-template-columns: 48px 1fr 38px;
    padding: 13px;
  }

  .bar {
    align-items: flex-start;
  }

  .stats {
    max-width: 72%;
  }

  .board {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .lines {
    display: none;
  }

  .footer-actions {
    grid-template-columns: 1fr;
  }

  .game-grid,
  .crossword-layout,
  .builder-layout {
    grid-template-columns: 1fr;
  }

  .game-tile {
    grid-template-columns: 54px 1fr;
    min-height: 142px;
    padding: 16px;
  }

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

  .tile-action {
    grid-column: 1 / -1;
  }

  .set-card,
  .question-row {
    grid-template-columns: 1fr;
  }

  .set-actions,
  .clue-toolbar {
    grid-template-columns: 1fr;
  }

  .clue-panel {
    position: static;
  }
}
