:root {
  --bg: #0a0a0f;
  --panel: #11121a;
  --panel-2: #151826;
  --text: #d8e8ff;
  --muted: #8aa0bf;
  --green: #00ff88;
  --red: #ff0066;
  --cyan: #00ccff;
  --yellow: #ffe066;
}

* {
  box-sizing: border-box;
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at 20% 10%, rgba(0, 204, 255, 0.08), transparent 45%),
    radial-gradient(circle at 80% 90%, rgba(255, 0, 102, 0.08), transparent 40%),
    var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace, system-ui;
  overscroll-behavior-y: contain;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--cyan);
  text-decoration: none;
}

.container {
  width: min(980px, 92vw);
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 0 calc(28px + env(safe-area-inset-bottom));
}

.title {
  margin: 0;
  font-size: clamp(1.9rem, 4.2vw, 3rem);
  letter-spacing: 0.08em;
  color: var(--green);
  text-shadow: 0 0 14px rgba(0, 255, 136, 0.5);
}

.subtitle {
  margin: 8px 0 24px;
  color: var(--muted);
  font-size: 0.95rem;
}

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

.game-card {
  border: 1px solid rgba(0, 204, 255, 0.35);
  background: linear-gradient(160deg, rgba(0, 204, 255, 0.06), rgba(255, 0, 102, 0.06));
  border-radius: 12px;
  padding: 14px;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.game-card:hover,
.game-card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--green);
  box-shadow: 0 0 16px rgba(0, 255, 136, 0.22);
  outline: none;
}

.game-name {
  margin: 0;
  color: var(--green);
  font-size: 1.08rem;
}

.game-desc {
  margin: 0;
  color: var(--text);
  line-height: 1.35;
  font-size: 0.92rem;
}

.badge {
  display: inline-block;
  width: fit-content;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge.easy {
  color: var(--green);
  border: 1px solid rgba(0, 255, 136, 0.6);
}

.badge.medium {
  color: var(--cyan);
  border: 1px solid rgba(0, 204, 255, 0.6);
}

.badge.hard {
  color: var(--red);
  border: 1px solid rgba(255, 0, 102, 0.6);
}

.back-btn {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--cyan);
  border: 1px solid rgba(0, 204, 255, 0.45);
  border-radius: 8px;
  padding: 7px 11px;
}

.back-btn:hover,
.back-btn:focus-visible {
  border-color: var(--green);
  color: var(--green);
}

.panel {
  background: linear-gradient(170deg, rgba(0, 255, 136, 0.05), rgba(0, 204, 255, 0.04));
  border: 1px solid rgba(0, 204, 255, 0.35);
  border-radius: 12px;
  padding: 14px;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  margin-bottom: 12px;
}

.hud span {
  color: var(--text);
}

.btn,
button {
  font: inherit;
  color: var(--text);
  background: rgba(0, 204, 255, 0.12);
  border: 1px solid rgba(0, 204, 255, 0.55);
  border-radius: 10px;
  padding: 10px 14px;
  min-height: 44px;
  cursor: pointer;
  font-weight: 600;
}

.btn:hover,
button:hover,
.btn:focus-visible,
button:focus-visible {
  border-color: var(--green);
  box-shadow: 0 0 10px rgba(0, 255, 136, 0.25);
  outline: none;
}

.btn.red {
  border-color: rgba(255, 0, 102, 0.7);
  background: rgba(255, 0, 102, 0.12);
}

.btn.green {
  border-color: rgba(0, 255, 136, 0.7);
  background: rgba(0, 255, 136, 0.12);
}

.status {
  min-height: 1.25em;
  font-weight: 600;
}

.big-display {
  font-size: clamp(2rem, 10vw, 4rem);
  text-align: center;
  margin: 18px 0;
  color: var(--green);
  text-shadow: 0 0 18px rgba(0, 255, 136, 0.45);
}

.neon-cyan {
  color: var(--cyan);
}

.neon-red {
  color: var(--red);
}

.neon-green {
  color: var(--green);
}

.tap-area {
  border: 1px dashed rgba(0, 204, 255, 0.55);
  border-radius: 12px;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
  user-select: none;
}

.flash-red {
  animation: flashRed 200ms linear;
}

@keyframes flashRed {
  from {
    box-shadow: 0 0 0 rgba(255, 0, 102, 0.9);
    background: rgba(255, 0, 102, 0.25);
  }

  to {
    box-shadow: 0 0 0 rgba(255, 0, 102, 0);
    background: transparent;
  }
}

.canvas-wrap {
  width: min(96vw, 430px);
  margin: 0 auto;
  border: 1px solid rgba(0, 204, 255, 0.45);
  border-radius: 12px;
  padding: 8px;
  background: rgba(17, 18, 26, 0.8);
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  background: #090a12;
  border-radius: 8px;
  image-rendering: pixelated;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.pixel-box {
  min-height: 170px;
  border: 1px solid rgba(0, 255, 136, 0.5);
  border-radius: 12px;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
  font-size: clamp(4rem, 13vw, 6rem);
}

.grid-4 {
  width: min(96vw, 430px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.cell {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  border: 1px solid rgba(0, 204, 255, 0.5);
  background: rgba(0, 204, 255, 0.08);
}

.cell.active {
  background: rgba(0, 255, 136, 0.5);
  border-color: var(--green);
  box-shadow: 0 0 14px rgba(0, 255, 136, 0.35);
}

.cell.correct {
  background: rgba(0, 255, 136, 0.3);
}

.cell.wrong {
  background: rgba(255, 0, 102, 0.35);
}

input,
textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: rgba(10, 10, 15, 0.85);
  border: 1px solid rgba(0, 204, 255, 0.55);
  border-radius: 8px;
  padding: 10px;
  min-height: 44px;
  font-size: 16px;
}

.track {
  position: relative;
  width: 100%;
  height: 80px;
  border-radius: 10px;
  border: 1px solid rgba(0, 204, 255, 0.45);
  background: linear-gradient(90deg, rgba(255, 0, 102, 0.1), rgba(0, 204, 255, 0.05));
  overflow: hidden;
}

.runner,
.monster {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
}

.runner {
  filter: drop-shadow(0 0 8px rgba(0, 255, 136, 0.6));
}

.monster {
  filter: drop-shadow(0 0 8px rgba(255, 0, 102, 0.7));
}

.clock {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  margin: 0 auto;
  border: 2px solid rgba(0, 204, 255, 0.6);
  position: relative;
  box-shadow: 0 0 16px rgba(0, 204, 255, 0.2);
}

.clock-hand {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 70px;
  background: var(--green);
  transform-origin: 50% 90%;
  transform: translate(-50%, -90%) rotate(0deg);
  border-radius: 3px;
}

.word-target {
  font-size: clamp(1.5rem, 7vw, 2.6rem);
  text-align: center;
  margin: 8px 0 14px;
}

.mobile-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.mobile-controls button {
  min-height: 50px;
  font-size: 1rem;
}

@media (max-width: 700px) {
  .container {
    width: 94vw;
    padding-top: calc(12px + env(safe-area-inset-top));
  }

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

  .hud {
    gap: 6px 10px;
    font-size: 0.92rem;
  }

  .tap-area {
    min-height: 150px;
  }

  .btn,
  button {
    min-height: 48px;
    font-size: 0.98rem;
  }
}
