/* ── RHYTHMIC TIC TAC TOE — NEON ARENA SKIN ── */

@font-face {
  font-family: 'FontNotas';
  src: url('../fonts/fontnotas.ttf') format('truetype');
  font-display: swap;
}

@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Sans:wght@400;500;600;700&display=swap');

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #080c18;
  --bg2: #0d1225;
  --surface: #111828;
  --surface2: #171f32;
  --surface3: #1e2840;
  --cyan: #00e8ff;
  --cyan-dim: rgba(0, 232, 255, 0.18);
  --cyan-glow: rgba(0, 232, 255, 0.35);
  --magenta: #d946ef;
  --mag-dim: rgba(217, 70, 239, 0.18);
  --mag-glow: rgba(217, 70, 239, 0.35);
  --blue: #3b82f6;
  --gold: #f5c842;
  --ok: #4dcc7a;
  --bad: #ff4455;
  --text: #e8f0ff;
  --muted: #6a7a9e;
  --x-color: var(--magenta);
  --o-color: var(--cyan);
  --radius: 16px;
}

body {
  min-height: 100vh;
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(0, 232, 255, 0.07), transparent 50%),
    radial-gradient(ellipse at 80% 10%, rgba(217, 70, 239, 0.07), transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(59, 130, 246, 0.05), transparent 55%);
  padding: 1rem;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
}

body.game-active {
  overflow: hidden;
  padding: .5rem;
}

body.game-active .app {
  height: calc(100dvh - 1rem);
}

/* ── Panel base ── */
.panel {
  background: var(--surface);
  border: 1px solid rgba(0, 232, 255, 0.15);
  border-radius: 22px;
  padding: 1.2rem;
  box-shadow:
    0 0 60px rgba(0, 232, 255, 0.06),
    0 30px 60px rgba(0, 0, 0, 0.6);
  position: relative;
}

/* inner neon border */
.panel::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(217, 70, 239, 0.08);
  border-radius: 17px;
  pointer-events: none;
}

.hidden {
  display: none !important;
}

/* ── Back link ── */
.back-link {
  display: inline-block;
  margin-bottom: 0.6rem;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: .9rem;
  transition: color .2s;
}

.back-link:hover {
  color: var(--cyan);
}

/* ── Logo ── */
.game-logo {
  width: min(380px, 90%);
  display: block;
  margin: 0 auto .4rem;
  filter:
    drop-shadow(0 6px 28px rgba(0, 232, 255, 0.4)) drop-shadow(0 0 60px rgba(217, 70, 239, 0.25));
  animation: logo-float 4s ease-in-out infinite;
}

@keyframes logo-float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-7px);
  }
}

/* ── Eyebrow ── */
.eyebrow {
  font-family: 'Bebas Neue', sans-serif;
  text-transform: uppercase;
  letter-spacing: .2em;
  font-size: .85rem;
  color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan-glow);
}

.eyebrow.small {
  font-size: .72rem;
}

/* ── Headings ── */
h1,
h2,
h3 {
  font-family: 'Bebas Neue', sans-serif;
  line-height: 1.05;
  letter-spacing: .08em;
}

h1 {
  font-size: clamp(2rem, 6vw, 3.2rem);
  margin-top: .2rem;
  color: var(--text);
  display: none;
  /* logo replaces */
}

.subtitle {
  color: var(--muted);
  font-size: .95rem;
  margin-top: .2rem;
  font-weight: 500;
}

/* ── Setup grid ── */
.setup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: .8rem;
}

.setup-card {
  background: var(--surface2);
  border: 1px solid rgba(0, 232, 255, 0.1);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: .8rem;
  position: relative;
  z-index: 1;
}

.setup-card h2 {
  font-size: 1.1rem;
  margin-bottom: .6rem;
  color: var(--cyan);
  text-shadow: 0 0 8px var(--cyan-glow);
  letter-spacing: .12em;
}

.field-row {
  display: grid;
  gap: .3rem;
  margin-top: .55rem;
}

.field-row label {
  font-weight: 600;
  color: var(--muted);
  font-size: .88rem;
}

.player-inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
  gap: .4rem;
  align-items: center;
}

input[type="text"],
input[type="range"],
.marker-select {
  width: 100%;
}

input[type="text"] {
  background: var(--surface3);
  color: var(--text);
  border: 1px solid rgba(0, 232, 255, 0.18);
  border-radius: 9px;
  padding: .5rem .7rem;
  font-size: .95rem;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  transition: border-color .2s;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 10px var(--cyan-dim);
}

.marker-select {
  background: var(--surface3);
  color: var(--text);
  border: 1px solid rgba(217, 70, 239, 0.2);
  border-radius: 9px;
  padding: .5rem .6rem;
  font-size: .95rem;
  font-weight: 700;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
}

.marker-select:focus {
  outline: 2px solid var(--magenta);
}

input[type="range"] {
  accent-color: var(--cyan);
  cursor: pointer;
}

.setup-error {
  min-height: 1rem;
  margin-top: .45rem;
  color: var(--bad);
  font-weight: 700;
  font-size: .88rem;
}

/* ── Meter buttons ── */
.meter-options {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

button {
  border: none;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
}

.meter {
  padding: .45rem .9rem;
  border-radius: 999px;
  background: var(--surface3);
  color: var(--muted);
  font-weight: 700;
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: .1em;
  font-size: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: background .15s, color .15s, box-shadow .15s;
}

.meter.active {
  background: var(--surface3);
  color: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 14px var(--cyan-dim);
}

/* ── Figure toggles ── */
.figure-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: .55rem;
}

.figure {
  background: var(--surface3);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: .6rem .5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .22rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.figure .symbol {
  font-family: 'FontNotas', sans-serif;
  font-size: 2rem;
  line-height: 1;
  color: var(--text);
}

.figure .name {
  font-size: .7rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}

.figure.active {
  background: rgba(0, 232, 255, 0.07);
  border-color: var(--cyan);
  box-shadow: 0 0 10px var(--cyan-dim);
}

.figure.active .symbol {
  color: var(--cyan);
}

.figure.active .name {
  color: var(--cyan);
}

/* ── CTA button ── */
.cta {
  margin-top: 1rem;
  width: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--blue));
  color: #000;
  border-radius: 999px;
  padding: .85rem 1.1rem;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.3rem;
  letter-spacing: .14em;
  cursor: pointer;
  box-shadow: 0 4px 22px rgba(0, 232, 255, 0.35);
  transition: transform .15s, box-shadow .15s;
  position: relative;
  z-index: 1;
}

.cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(0, 232, 255, 0.5);
}

/* ── Game header ── */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

.game-header h2 {
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  color: var(--text);
  letter-spacing: .08em;
}

.game-message {
  margin-top: .2rem;
  color: var(--muted);
  font-weight: 600;
  font-size: .9rem;
}

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

/* ── Ghost buttons ── */
.ghost {
  border-radius: 9px;
  background: var(--surface2);
  color: var(--muted);
  font-weight: 600;
  padding: .5rem .7rem;
  font-size: .85rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: color .2s, border-color .2s;
}

.ghost:hover {
  color: var(--cyan);
  border-color: var(--cyan);
}

.ghost:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* ── Board ── */
.board {
  margin: .8rem auto 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: .65rem;
  width: min(86vw, calc(100dvh - 230px), 760px);
  aspect-ratio: 1 / 1;
  align-self: center;
}

.board-cell {
  position: relative;
  background: var(--surface2);
  border: 1px solid rgba(0, 232, 255, 0.15);
  border-radius: var(--radius);
  aspect-ratio: 1 / 1;
  padding: .55rem;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}

.board-cell:hover:not(.marked) {
  transform: translateY(-2px);
  border-color: var(--cyan);
  box-shadow: 0 0 20px var(--cyan-dim), 0 10px 20px rgba(0, 0, 0, 0.4);
}

.cell-rhythm {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--text);
}

.cell-rhythm-track {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .18rem;
  transform-origin: center center;
  will-change: transform;
  font-family: 'FontNotas', sans-serif;
  font-size: clamp(1.65rem, 2.6vw, 3.3rem);
  white-space: nowrap;
}

.board-cell.marked .cell-rhythm {
  opacity: .12;
}

.board-cell.win {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(245, 200, 66, 0.3), 0 0 30px rgba(245, 200, 66, 0.2);
}

/* Marked by X or O */
.board-cell.marked-x {
  border-color: rgba(217, 70, 239, 0.4);
  background: rgba(217, 70, 239, 0.05);
}

.board-cell.marked-o {
  border-color: rgba(0, 232, 255, 0.4);
  background: rgba(0, 232, 255, 0.05);
}

.cell-mark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Bebas Neue', sans-serif;
  font-weight: 400;
  font-size: clamp(3rem, 8vw, 7rem);
  letter-spacing: .05em;
}

.mark-player-x {
  color: var(--magenta);
  text-shadow: 0 0 30px var(--mag-glow), 0 0 60px rgba(217, 70, 239, 0.3);
}

.mark-player-o {
  color: var(--cyan);
  text-shadow: 0 0 30px var(--cyan-glow), 0 0 60px rgba(0, 232, 255, 0.3);
}

/* ── Overlays ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 18, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 999;
}

/* ── Challenge card ── */
.challenge-card {
  width: min(1080px, 96vw);
  border-radius: 22px;
  background: var(--surface);
  border: 1px solid rgba(0, 232, 255, 0.2);
  padding: 1.2rem;
  box-shadow:
    0 0 60px rgba(0, 232, 255, 0.1),
    0 30px 60px rgba(0, 0, 0, 0.7);
  text-align: center;
  position: relative;
}

.challenge-card::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(217, 70, 239, 0.08);
  border-radius: 17px;
  pointer-events: none;
}

.challenge-card h3 {
  font-size: clamp(1.4rem, 5vw, 2.4rem);
  color: var(--cyan);
  text-shadow: 0 0 20px var(--cyan-glow);
  letter-spacing: .1em;
  position: relative;
  z-index: 1;
}

#challenge-help {
  color: var(--muted);
  margin-top: .2rem;
  font-weight: 500;
  position: relative;
  z-index: 1;
}

.challenge-rhythm {
  margin: .9rem 0 .6rem;
  min-height: clamp(120px, 24vh, 220px);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: .35rem;
  position: relative;
  z-index: 1;
}

.challenge-note {
  font-family: 'FontNotas', sans-serif;
  font-size: clamp(4rem, 10vw, 8.5rem);
  line-height: 1;
  border-radius: 10px;
  padding: .1rem .2rem;
  transition: background .12s, transform .12s;
  color: var(--text);
}

.challenge-note.active {
  background: rgba(245, 200, 66, 0.15);
  color: var(--gold);
  transform: translateY(-4px);
  text-shadow: 0 0 20px rgba(245, 200, 66, 0.5);
}

.challenge-note.good {
  color: var(--ok);
}

.challenge-note.bad {
  color: var(--bad);
}

.challenge-feedback {
  min-height: 1.5rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--muted);
  position: relative;
  z-index: 1;
}

.challenge-actions {
  margin-top: .8rem;
  display: flex;
  justify-content: center;
  gap: .65rem;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

/* ── TAP button ── */
.tap-btn {
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  color: #000;
  border-radius: 12px;
  padding: .6rem 1.1rem;
  font-family: 'Bebas Neue', sans-serif;
  font-weight: 400;
  font-size: 1.2rem;
  letter-spacing: .14em;
  min-width: 110px;
  box-shadow: 0 4px 18px var(--cyan-dim);
  transition: transform .1s, box-shadow .1s;
}

.tap-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.tap-btn.flash {
  transform: scale(1.05);
  box-shadow: 0 0 28px var(--cyan-glow);
}

/* ── Result card ── */
.result-card {
  width: min(620px, 95vw);
  border-radius: 22px;
  background: var(--surface);
  border: 1px solid rgba(245, 200, 66, 0.3);
  padding: 1.4rem;
  box-shadow:
    0 0 50px rgba(245, 200, 66, 0.08),
    0 30px 60px rgba(0, 0, 0, 0.7);
  text-align: center;
}

.result-card h3 {
  font-size: clamp(2rem, 5vw, 3rem);
  color: var(--gold);
  text-shadow: 0 0 24px rgba(245, 200, 66, 0.5);
  letter-spacing: .1em;
}

#result-subtitle {
  margin-top: .3rem;
  color: var(--muted);
  font-weight: 600;
  font-size: 1.05rem;
}

.result-actions {
  margin-top: .9rem;
  display: flex;
  justify-content: center;
  gap: .6rem;
  flex-wrap: wrap;
}

/* ── Confetti ── */
.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1400;
}

.confetti-piece {
  position: absolute;
  top: -14px;
  width: 10px;
  height: 16px;
  border-radius: 2px;
  opacity: .95;
  animation-name: confettiFall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

@keyframes confettiFall {
  from {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }

  to {
    transform: translateY(110vh) rotate(540deg);
    opacity: .95;
  }
}

/* ── Game screen ── */
#game-screen {
  min-height: calc(100dvh - 1rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#game-screen.hidden {
  display: none !important;
}

/* ── Responsive ── */
@media (max-width: 760px) {
  .board {
    grid-template-columns: repeat(3, 1fr);
  }

  .challenge-card {
    padding: .85rem;
  }

  .board {
    width: min(94vw, calc(100dvh - 220px));
    gap: .4rem;
  }

  .board-cell {
    border-radius: 12px;
    padding: .35rem;
  }

  .cell-rhythm-track {
    font-size: clamp(1.3rem, 5.5vw, 2.35rem);
  }

  .player-inline {
    grid-template-columns: minmax(0, 1fr) 76px;
  }

  .game-logo {
    width: min(300px, 85%);
  }
}

/* ── Premium Locks ── */
.locked-premium {
  position: relative;
  opacity: 0.65;
  cursor: not-allowed !important;
}

.locked-premium>* {
  pointer-events: none;
}

.locked-premium::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  background-color: rgba(255, 255, 255, 0.45);
  mask-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12 2C9.243 2 7 4.243 7 7V10H6V20H18V10H17V7C17 4.243 14.757 2 12 2ZM9 7C9 5.346 10.346 4 12 4C13.654 4 15 5.346 15 7V10H9V7ZM12 17C10.895 17 10 16.105 10 15C10 13.895 10.895 13 12 13C13.105 13 14 13.895 14 15C14 16.105 13.105 17 12 17Z" fill="white"/></svg>');
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12 2C9.243 2 7 4.243 7 7V10H6V20H18V10H17V7C17 4.243 14.757 2 12 2ZM9 7C9 5.346 10.346 4 12 4C13.654 4 15 5.346 15 7V10H9V7ZM12 17C10.895 17 10 16.105 10 15C10 13.895 10.895 13 12 13C13.105 13 14 13.895 14 15C14 16.105 13.105 17 12 17Z" fill="white"/></svg>');
  mask-size: contain;
  -webkit-mask-size: contain;
  mask-repeat: no-repeat;
  -webkit-mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-position: center;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}