:root {
  /* Glassmorphism dashboard theme for the Computer Adventure game UI */
  --ink: #102742;
  --muted: #5d6d7e;
  --gold: #f2c24f;
  --gold-deep: #bd8324;
  --blue: #182b60;
  --cyan: #41d4ff;
  --pink: #ff6aa2;
  --green: #44d18d;
  --paper: rgba(255, 255, 255, .84);
  --glass: rgba(14, 32, 70, .52);
  --line: rgba(255, 255, 255, .28);
  --shadow: 0 24px 70px rgba(8, 18, 44, .32);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
  margin: 0;
  font-family: "Sarabun", "Noto Sans Thai", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #fff;
  background:
    radial-gradient(circle at 18% 18%, rgba(65, 212, 255, .34), transparent 30%),
    radial-gradient(circle at 84% 12%, rgba(255, 106, 162, .28), transparent 28%),
    linear-gradient(135deg, #08162e 0%, #132b62 48%, #35194f 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.9), rgba(0,0,0,.18));
}

button, input { font: inherit; }

.game-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 2vw, 32px);
}

.hero-panel,
.canvas-card,
.side-panel article,
.modal-card {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(255,255,255,.2), rgba(255,255,255,.08));
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.hero-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: clamp(20px, 3vw, 36px);
  border-radius: 34px;
  position: relative;
  overflow: hidden;
}

.hero-panel::after {
  content: "⌘";
  position: absolute;
  right: 7%;
  top: -42px;
  font-size: 170px;
  color: rgba(255,255,255,.08);
  animation: floatSymbol 7s ease-in-out infinite;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-weight: 800;
  letter-spacing: .02em;
}

h1, h2 { margin: 0; line-height: 1.15; }

h1 {
  font-size: clamp(2.6rem, 6vw, 6.4rem);
  letter-spacing: -.05em;
  text-shadow: 0 12px 40px rgba(0,0,0,.34);
}

.lead {
  max-width: 760px;
  margin: 16px 0 0;
  color: rgba(255,255,255,.82);
  font-size: clamp(1.05rem, 1.5vw, 1.35rem);
}

.hero-actions,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
}

.btn, .icon-button {
  border: 0;
  cursor: pointer;
  border-radius: 18px;
  font-weight: 900;
  transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}

.btn {
  padding: 14px 22px;
  min-height: 54px;
  text-decoration: none;
}

.btn:hover, .icon-button:hover { transform: translateY(-2px); filter: brightness(1.05); }
.btn:active, .icon-button:active { transform: translateY(0) scale(.98); }

.btn-gold {
  color: #221607;
  background: linear-gradient(135deg, #ffe27a, #f4bd3d 55%, #d58d24);
  box-shadow: 0 15px 32px rgba(242, 194, 79, .28);
}

.btn-ghost, .icon-button {
  color: #fff;
  background: rgba(255,255,255,.13);
  border: 1px solid rgba(255,255,255,.28);
}

.icon-button {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
}

.hud-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(110px, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.hud-card {
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 22px;
  padding: 14px 16px;
  background: rgba(255,255,255,.1);
  box-shadow: 0 14px 36px rgba(0,0,0,.16);
}

.hud-card span {
  display: block;
  color: rgba(255,255,255,.7);
  font-size: .92rem;
}

.hud-card strong {
  display: block;
  margin-top: 4px;
  font-size: 1.5rem;
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
}

.canvas-card {
  border-radius: 30px;
  overflow: hidden;
  padding: 16px;
}

.game-topline {
  display: grid;
  grid-template-columns: 1fr minmax(180px, 320px);
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
}

.progress-wrap {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
}

.progress-wrap span {
  display: block;
  width: 5%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--cyan), var(--gold));
  transition: width .35s ease;
}

#gameCanvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 22px;
  background: #0c1f45;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16);
  touch-action: none;
}

.side-panel {
  display: grid;
  gap: 18px;
  align-content: start;
}

.side-panel article {
  border-radius: 26px;
  padding: 18px;
}

.side-panel h2 {
  margin-bottom: 14px;
  font-size: 1.2rem;
}

#miniMap {
  width: 100%;
  height: auto;
  border-radius: 18px;
  background: rgba(8, 18, 44, .6);
}

.badge-grid {
  display: grid;
  gap: 10px;
}

.badge {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 16px;
  color: rgba(255,255,255,.82);
  background: rgba(255,255,255,.1);
}

.badge.unlocked {
  color: #fff;
  background: linear-gradient(135deg, rgba(68,209,141,.28), rgba(242,194,79,.2));
}

.leaderboard {
  margin: 0;
  padding-left: 24px;
}

.leaderboard li {
  margin: 8px 0;
  color: rgba(255,255,255,.82);
}

.mobile-controls {
  display: none;
  grid-template-columns: repeat(3, 64px);
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

.mobile-controls button {
  width: 64px;
  height: 56px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 18px;
  color: #fff;
  background: rgba(255,255,255,.14);
  font-weight: 900;
}

.mobile-controls button[data-dir="up"] { grid-column: 2; }
.mobile-controls button[data-dir="left"] { grid-column: 1; }
.mobile-controls button[data-dir="down"] { grid-column: 2; }
.mobile-controls button[data-dir="right"] { grid-column: 3; grid-row: 2; }

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(3, 8, 20, .72);
  z-index: 30;
}

.modal[hidden] { display: none; }

.modal-card {
  width: min(720px, 100%);
  border-radius: 30px;
  padding: clamp(20px, 4vw, 34px);
  animation: popIn .24s ease both;
}

.quiz-card h2 {
  font-size: clamp(1.6rem, 4vw, 2.6rem);
}

.answer-grid {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.answer-grid button,
.match-card {
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 18px;
  padding: 15px;
  color: #fff;
  text-align: left;
  cursor: pointer;
  background: rgba(255,255,255,.12);
  transition: transform .2s ease, background .2s ease;
}

.answer-grid button:hover,
.match-card:hover { transform: translateX(4px); background: rgba(255,255,255,.18); }

.answer-grid button.correct { background: rgba(68,209,141,.36); }
.answer-grid button.wrong { background: rgba(255,91,91,.36); }

.feedback {
  min-height: 32px;
  margin: 14px 0 0;
  font-weight: 800;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 18px 0;
}

.result-grid div {
  border-radius: 18px;
  padding: 14px;
  background: rgba(255,255,255,.12);
}

.result-grid span {
  display: block;
  color: rgba(255,255,255,.72);
  font-size: .9rem;
}

.result-grid strong {
  display: block;
  font-size: 1.7rem;
}

.name-field {
  display: grid;
  gap: 8px;
  margin: 12px 0 18px;
  font-weight: 800;
}

.name-field input {
  width: 100%;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 16px;
  padding: 14px 16px;
  color: #fff;
  background: rgba(255,255,255,.12);
}

.match-board {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 18px 0;
}

.match-card.selected {
  outline: 3px solid var(--gold);
  background: rgba(242, 194, 79, .22);
}

.match-card.done {
  pointer-events: none;
  opacity: .58;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(120px);
  max-width: min(520px, calc(100% - 32px));
  border-radius: 18px;
  padding: 14px 18px;
  color: #11203b;
  background: rgba(255, 226, 122, .96);
  box-shadow: 0 16px 46px rgba(0,0,0,.28);
  font-weight: 900;
  transition: transform .25s ease;
  z-index: 40;
}

.toast.show { transform: translateX(-50%) translateY(0); }

@keyframes floatSymbol {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(24px) rotate(6deg); }
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(18px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 1180px) {
  .hud-grid { grid-template-columns: repeat(4, 1fr); }
  .play-layout { grid-template-columns: 1fr; }
  .side-panel { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 760px) {
  .game-shell { padding: 10px; }
  .hero-panel { align-items: flex-start; flex-direction: column; border-radius: 24px; }
  .hero-actions { justify-content: flex-start; }
  .hud-grid, .side-panel { grid-template-columns: repeat(2, 1fr); }
  .game-topline, .result-grid, .match-board { grid-template-columns: 1fr; }
  .mobile-controls { display: grid; }
  h1 { font-size: 2.8rem; }
}

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