/* @section: design-system */
:root {
  color-scheme: light;
  --bg: #fff7ec;
  --bg-deep: #f5d6a6;
  --surface: rgba(255, 255, 255, 0.84);
  --surface-solid: #fffdf8;
  --text: #2b241c;
  --muted: #776653;
  --border: rgba(118, 82, 45, 0.18);
  --primary: #e77942;
  --primary-strong: #b94d24;
  --accent: #2aa7a3;
  --tile: #fff4d9;
  --tile-strong: #ffd06f;
  --shadow: 0 24px 70px rgba(126, 70, 22, 0.18);
  --radius: 26px;
  font-family: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 209, 112, 0.52), transparent 32rem),
    radial-gradient(circle at 88% 22%, rgba(42, 167, 163, 0.28), transparent 26rem),
    linear-gradient(135deg, #fffaf0 0%, var(--bg) 44%, #f7e3c2 100%);
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  width: 18rem;
  height: 18rem;
  border-radius: 38% 62% 58% 42%;
  background: rgba(255, 255, 255, 0.28);
  filter: blur(1px);
  pointer-events: none;
  z-index: -1;
}

body::before { left: -5rem; bottom: 7rem; transform: rotate(24deg); }
body::after { right: -4rem; top: 4rem; transform: rotate(-18deg); }

button, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

/* @section: app-shell */
.game-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(280px, 0.92fr) minmax(320px, 1.08fr);
  gap: clamp(1rem, 3vw, 2.5rem);
  align-items: center;
  padding: clamp(1.4rem, 4vw, 4rem) 0;
}

.intro-panel,
.play-panel {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.intro-panel {
  min-height: 620px;
  border-radius: 36px;
  padding: clamp(1.5rem, 4vw, 3.5rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.intro-panel::after {
  content: "";
  position: absolute;
  width: 13rem;
  height: 13rem;
  right: -3rem;
  bottom: -2rem;
  background:
    linear-gradient(90deg, rgba(255,255,255,.34) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,.34) 1px, transparent 1px),
    linear-gradient(135deg, rgba(231,121,66,.28), rgba(42,167,163,.18));
  background-size: 2.4rem 2.4rem, 2.4rem 2.4rem, 100% 100%;
  border-radius: 32px;
  transform: rotate(-10deg);
}

.brand-row { display: flex; align-items: center; gap: .7rem; margin-bottom: 3.4rem; }
.logo-mark { width: 34px; height: 34px; border-radius: 12px; background: conic-gradient(from 45deg, var(--primary), var(--tile-strong), var(--accent), var(--primary)); box-shadow: 0 8px 18px rgba(231,121,66,.28); }
.brand-name { font-weight: 900; letter-spacing: -0.03em; }
.eyebrow { margin: 0 0 .85rem; color: var(--primary-strong); font-weight: 900; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; }
h1 { max-width: 650px; margin: 0 0 1.2rem; font-size: clamp(1.25rem, 3vw, 2.7rem); line-height: 1.08; letter-spacing: -0.045em; }
.lead { max-width: 560px; margin: 0; color: var(--muted); font-size: clamp(1rem, 1.8vw, 1.18rem); line-height: 1.75; }
.quick-rules { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-top: 2.2rem; position: relative; z-index: 1; }
.quick-rules div { padding: .9rem; border: 1px solid var(--border); border-radius: 18px; background: rgba(255,255,255,.56); }
.quick-rules strong, .quick-rules span { display: block; }
.quick-rules strong { font-size: .85rem; }
.quick-rules span { color: var(--muted); font-size: .78rem; margin-top: .18rem; }

/* @section: game-panel */
.play-panel { border-radius: 34px; padding: clamp(1rem, 2.6vw, 2rem); }
.status-card { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-bottom: 1rem; }
.stat { border-radius: 20px; background: rgba(255,253,248,.72); border: 1px solid var(--border); padding: .85rem 1rem; }
.stat span { display: block; color: var(--muted); font-size: .8rem; font-weight: 700; }
.stat strong { display: block; margin-top: .12rem; font-size: clamp(1.12rem, 2.2vw, 1.55rem); letter-spacing: -0.04em; }

.board-wrap { position: relative; border-radius: 28px; padding: clamp(.75rem, 2vw, 1.1rem); background: linear-gradient(145deg, rgba(119,83,43,.15), rgba(255,255,255,.45)); border: 1px solid rgba(118,82,45,.2); }
.puzzle-board { --size: 3; display: grid; grid-template-columns: repeat(var(--size), 1fr); gap: clamp(.45rem, 1.1vw, .75rem); aspect-ratio: 1; width: min(100%, 560px); margin: 0 auto; }
.tile {
  border: 0;
  border-radius: clamp(14px, 2.8vw, 24px);
  background:
    linear-gradient(145deg, rgba(255,255,255,.52), rgba(255,255,255,0)),
    linear-gradient(135deg, var(--tile), var(--tile-strong));
  box-shadow: inset 0 -5px 0 rgba(116,66,18,.1), 0 12px 24px rgba(126,70,22,.14);
  color: #442f17;
  font-size: clamp(1.7rem, 6vw, 3.2rem);
  font-weight: 950;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease, opacity .18s ease;
  position: relative;
}
.tile::after { content: ""; position: absolute; inset: 14%; border-radius: inherit; border: 1px solid rgba(255,255,255,.48); pointer-events: none; }
.tile:hover:not(:disabled), .tile:focus-visible { transform: translateY(-3px) scale(1.015); box-shadow: inset 0 -5px 0 rgba(116,66,18,.1), 0 18px 30px rgba(126,70,22,.18); outline: none; }
.tile.movable { filter: saturate(1.1); }
.tile.empty { opacity: .08; cursor: default; box-shadow: none; background: rgba(255,255,255,.35); }
.tile.hint { animation: pulseHint .8s ease-in-out 3; }

.controls { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: .75rem; margin-top: 1rem; align-items: stretch; }
.primary-btn, .ghost-btn, select { min-height: 3.2rem; border-radius: 18px; border: 1px solid var(--border); padding: .65rem 1rem; font-weight: 900; cursor: pointer; transition: transform .16s ease, background .16s ease, box-shadow .16s ease; }
.primary-btn { background: var(--primary); color: white; border-color: rgba(185,77,36,.24); box-shadow: 0 14px 26px rgba(231,121,66,.24); }
.ghost-btn, select { background: rgba(255,255,255,.64); color: var(--text); }
.primary-btn:hover, .ghost-btn:hover, select:hover { transform: translateY(-2px); }
.select-label { display: grid; gap: .25rem; color: var(--muted); font-size: .74rem; font-weight: 800; }
select { width: 100%; appearance: none; color: var(--text); }
.message { min-height: 1.6rem; margin: .9rem .2rem 0; color: var(--muted); font-size: .92rem; }

.win-overlay { position: absolute; inset: 0; display: grid; place-items: center; border-radius: 28px; background: rgba(43,36,28,.2); backdrop-filter: blur(8px); }
.win-overlay[hidden] { display: none; }
.win-card { width: min(86%, 340px); border-radius: 28px; background: var(--surface-solid); box-shadow: var(--shadow); padding: 1.5rem; text-align: center; transform: translateY(0); animation: popIn .35s ease both; }
.win-card h2 { margin: .45rem 0 .35rem; font-size: 1.8rem; letter-spacing: -0.05em; }
.win-card p { margin: 0 0 1rem; color: var(--muted); }
.spark { display: inline-flex; align-items: center; justify-content: center; min-height: 2rem; padding: .2rem .7rem; border-radius: 999px; color: var(--primary-strong); background: #fff0cc; font-weight: 900; }

@keyframes popIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes pulseHint { 50% { transform: translateY(-5px) scale(1.04); box-shadow: 0 0 0 8px rgba(42,167,163,.16), 0 18px 30px rgba(126,70,22,.18); } }

@media (max-width: 900px) {
  .game-shell { grid-template-columns: 1fr; align-items: start; }
  .intro-panel { min-height: auto; }
  .quick-rules { grid-template-columns: 1fr 1fr 1fr; }
}

@media (max-width: 560px) {
  .game-shell { width: min(100% - 20px, 1180px); padding: .8rem 0 1.3rem; }
  .intro-panel, .play-panel { border-radius: 24px; }
  .brand-row { margin-bottom: 1.6rem; }
  .quick-rules { grid-template-columns: 1fr; }
  .status-card, .controls { grid-template-columns: 1fr; }
  .puzzle-board { gap: .42rem; }
  .tile { font-size: clamp(1.35rem, 10vw, 2.3rem); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
