:root {
  --bg-1: #122014;
  --bg-2: #28361f;
  --panel: rgba(25, 39, 24, 0.84);
  --panel-soft: rgba(35, 54, 32, 0.8);
  --border: rgba(181, 224, 168, 0.28);
  --text: #ecfdf5;
  --muted: #b6d4bf;
  --accent: #3a7d44;
  --accent-2: #7a4f2f;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
  --radius: 1rem;
  --font-heading: 'Trebuchet MS', 'Avenir Next', sans-serif;
  --font-body: 'Gill Sans', 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at 15% 10%, rgba(91, 171, 91, 0.24), transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(121, 77, 46, 0.26), transparent 42%),
    repeating-linear-gradient(145deg, rgba(255, 255, 255, 0.02) 0 12px, rgba(0, 0, 0, 0.03) 12px 24px),
    linear-gradient(135deg, var(--bg-2), var(--bg-1));
  padding: clamp(0.9rem, 2vw, 1.6rem);
}

body.game-lock-scroll {
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  padding: 0.5rem;
}

body.game-lock-scroll .hero {
  display: none;
}

body.game-lock-scroll .hub-app {
  width: min(1280px, 100%);
  height: calc(100dvh - 1rem);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.hub-app {
  width: min(1100px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 1rem;
}

.hero {
  text-align: center;
  padding: 1rem 0.4rem 0.2rem;
}

.eyebrow {
  margin: 0;
  color: #bef264;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.78rem;
  font-weight: 600;
}

.hero h1 {
  margin: 0.35rem 0 0;
  font-size: clamp(2rem, 5vw, 3.1rem);
  font-family: var(--font-heading);
}

.hero-copy {
  margin: 0.4rem auto 0;
  color: var(--muted);
  max-width: 48rem;
}

.account-strip {
  margin-top: 0.8rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

#accountStatus {
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(29, 55, 31, 0.72);
  color: #f0fdf4;
  font-size: 0.86rem;
}

.account-note {
  margin: 0.45rem 0 0;
  color: #9fb3da;
  font-size: 0.8rem;
}

.screen {
  display: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 0.25rem);
  box-shadow: var(--shadow);
  padding: clamp(0.85rem, 1.8vw, 1.35rem);
  backdrop-filter: blur(7px);
}

.screen-active {
  display: grid;
  gap: 0.9rem;
}

.screen-header {
  display: grid;
  gap: 0.35rem;
}

.screen-header h2 {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2rem);
}

.screen-header p {
  margin: 0;
  color: var(--muted);
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
}

.game-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: grid;
  gap: 0.6rem;
  background: linear-gradient(145deg, rgba(36, 61, 35, 0.94), rgba(24, 40, 27, 0.95));
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.game-card:hover {
  transform: translateY(-3px);
  border-color: rgba(190, 242, 100, 0.55);
  box-shadow: 0 16px 28px rgba(7, 17, 7, 0.45);
}

.game-card h2 {
  margin: 0;
  font-size: 1.35rem;
}

.game-card p {
  margin: 0;
  color: var(--muted);
}

.chip {
  font-size: 0.74rem;
  color: white;
  background: rgba(190, 242, 100, 0.24);
  width: fit-content;
  border-radius: 99px;
  padding: 0.2rem 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.snake-theme {
  background: linear-gradient(145deg, rgba(42, 86, 47, 0.95), rgba(20, 51, 27, 0.92));
}

.tap-theme {
  background: linear-gradient(145deg, rgba(64, 76, 39, 0.95), rgba(47, 48, 20, 0.92));
}

.color-theme {
  background: linear-gradient(145deg, rgba(32, 78, 64, 0.95), rgba(19, 55, 45, 0.92));
}

.alien-theme {
  background: linear-gradient(145deg, rgba(28, 72, 55, 0.95), rgba(17, 45, 30, 0.92));
}

.animal-theme {
  background: linear-gradient(145deg, rgba(102, 76, 44, 0.95), rgba(66, 48, 26, 0.92));
}

.brawler-theme {
  background: linear-gradient(145deg, rgba(67, 57, 36, 0.95), rgba(44, 36, 22, 0.92));
}

.stats {
  display: grid;
  gap: 0.65rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-card {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  text-align: center;
  padding: 0.55rem 0.6rem;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.76rem;
}

.stat-card strong {
  display: block;
  margin-top: 0.2rem;
  font-size: clamp(1.05rem, 2.8vw, 1.35rem);
}

.snake-shell {
  display: grid;
  grid-template-columns: clamp(3.2rem, 9vw, 4.2rem) minmax(220px, 1fr) clamp(3.2rem, 9vw, 4.2rem);
  align-items: center;
  gap: 0.6rem;
}

.game-panel {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(24, 40, 27, 0.92);
  padding: 0.6rem;
}

#gameCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 0.7rem;
  background: #1a2c1d;
  image-rendering: pixelated;
}

.overlay {
  position: absolute;
  inset: 0.6rem;
  border-radius: 0.7rem;
  background: rgba(6, 12, 28, 0.82);
  display: grid;
  place-content: center;
  text-align: center;
  padding: 1rem;
}

.overlay h3 {
  margin: 0;
  font-size: 1.45rem;
}

.overlay p {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

.turn-btn {
  width: 100%;
  min-width: 0;
  min-height: clamp(4.2rem, 16vw, 6rem);
  border-radius: 0.85rem;
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 700;
  padding: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.turn-btn:active {
  filter: brightness(1.15);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

button {
  border: none;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 0.75rem;
  padding: 0.62rem 1rem;
  font-size: 0.98rem;
  font-weight: 650;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease, opacity 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.secondary-btn {
  background: linear-gradient(135deg, #5064a5, #384b84);
}

.ghost-btn {
  justify-self: start;
  background: rgba(129, 145, 180, 0.2);
  border: 1px solid rgba(158, 174, 214, 0.32);
}

.tap-arena {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: radial-gradient(circle at center, rgba(86, 128, 68, 0.28), rgba(16, 31, 20, 0.95));
  height: clamp(240px, 48vh, 430px);
  overflow: hidden;
}

.tap-target {
  position: absolute;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45);
  background: radial-gradient(circle at 30% 30%, #ffec8a, #ff7735);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.08);
  padding: 0;
}

.mini-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  color: #e7f7e6;
  font-weight: 550;
  padding: 1rem;
  background: linear-gradient(165deg, rgba(18, 37, 22, 0.76), rgba(34, 33, 19, 0.72));
}

.color-stage {
  border: 1px solid var(--border);
  background: radial-gradient(circle at center, rgba(101, 138, 72, 0.3), rgba(20, 36, 24, 0.95));
  border-radius: var(--radius);
  text-align: center;
  padding: 1rem;
}

.color-prompt {
  margin: 0;
  color: var(--muted);
}

.color-word {
  margin: 0.65rem 0 0;
  font-size: clamp(2.3rem, 8vw, 3.8rem);
  line-height: 1;
}

.feedback {
  margin: 0.7rem 0 0;
  min-height: 1.3rem;
  color: #d8e6ff;
}

.dou-iframe-shell {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #182718;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

#douShouQiFrame {
  display: block;
  width: 100%;
  height: min(720px, calc(100dvh - 210px));
  border: 0;
  background: #182718;
}

body.game-lock-scroll #douShouQiScreen.screen-active {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

body.game-lock-scroll #douShouQiScreen .screen-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  flex: 0 0 auto;
}

body.game-lock-scroll #douShouQiScreen .screen-header p {
  flex-basis: 100%;
}

body.game-lock-scroll .dou-iframe-shell {
  width: 100%;
  max-width: none;
  flex: 1 1 auto;
  min-height: 0;
}

body.game-lock-scroll #douShouQiFrame {
  height: 100%;
  min-height: 0;
}

.feedback.good {
  color: #89f6af;
}

.feedback.bad {
  color: #ff9f9f;
}

.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(9, 18, 10, 0.78);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 20;
}

.modal.hidden {
  display: none;
}

.modal-panel {
  width: min(460px, 100%);
  border-radius: 0.9rem;
  border: 1px solid var(--border);
  background: rgba(24, 42, 25, 0.98);
  box-shadow: var(--shadow);
  padding: 1rem;
  display: grid;
  gap: 0.6rem;
}

.admin-panel {
  width: min(720px, 100%);
  max-height: min(88vh, 760px);
  overflow: auto;
}

.modal-panel h2,
.modal-panel h3,
.modal-panel p {
  margin: 0;
}

.modal-panel label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.86rem;
  color: #c8d4f0;
}

.modal-panel input,
.modal-panel select {
  width: 100%;
  border: 1px solid rgba(155, 172, 205, 0.35);
  border-radius: 0.55rem;
  background: rgba(19, 30, 18, 0.95);
  color: #e6eefc;
  padding: 0.5rem 0.6rem;
}

.modal-message {
  min-height: 1.1rem;
  color: #ffd58a;
  font-size: 0.85rem;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.admin-users {
  display: grid;
  gap: 0.4rem;
}

.admin-user {
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  padding: 0.6rem;
  background: rgba(20, 32, 60, 0.85);
  display: grid;
  gap: 0.45rem;
}

.admin-user-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
}

.admin-user-head strong {
  font-size: 0.95rem;
}

.admin-user-ops {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  align-items: center;
}

.admin-user-ops input,
.admin-user-ops select {
  width: auto;
  min-width: 120px;
  flex: 1;
}

@media (max-width: 860px) {
  .snake-shell {
    grid-template-columns: clamp(2.9rem, 12vw, 3.5rem) minmax(180px, 1fr) clamp(2.9rem, 12vw, 3.5rem);
  }
}

@media (pointer: coarse) {
  .turn-btn {
    min-height: clamp(5rem, 20vw, 7.2rem);
    font-size: clamp(1.8rem, 7vw, 2.3rem);
  }
}

@media (max-width: 560px) {
  body {
    padding: 0.65rem;
  }

  .stats {
    gap: 0.4rem;
  }

  .stat-card {
    padding: 0.45rem;
  }

  .turn-btn {
    min-height: clamp(4.5rem, 27vw, 6rem);
  }

  .actions {
    width: 100%;
  }

  .actions button {
    flex: 1;
    min-width: 0;
  }

  body.game-lock-scroll {
    padding: 0.35rem;
  }
}
