@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800;900&display=swap');

:root{
  --bg:#0a0e27;
  --panel: rgba(15, 21, 53, 0.92);
  --text:#eaf1ff;
  --muted:#9bb0df;

  --tileHover1:#00d4ff;
  --tileHover2:#0099ff;

  --stroke: rgba(0, 212, 255, 0.22);
  --glow: rgba(0, 212, 255, 0.18);

  --mx: 50%;
  --my: 50%;

  --radius: 18px;
  --pad: clamp(14px, 2.5vw, 26px);
}

*{ margin:0; padding:0; box-sizing:border-box; font-family:'Poppins',sans-serif; }
html, body{ height:100%; }

body{
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ✅ biar mobile bisa scroll & aman dari address bar */
.bg{
  position: relative;
  min-height: 100dvh;
  width: 100%;
  display: block;
  overflow: hidden;
  isolation: isolate;
}

/* Wrapper supaya konten center tapi tetap scroll */
.shell{
  position: relative;
  z-index: 5;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
           max(22px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Background grid */
.bg::before{
  content:"";
  position:absolute;
  inset:0;
  z-index:0;
  pointer-events:none;
  background:
    linear-gradient(to right, rgba(0,212,255,0.26) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0,212,255,0.26) 1px, transparent 1px);
  background-size: 120px 120px;
  opacity: 0.55;
  filter: drop-shadow(0 0 6px rgba(0,212,255,0.18));
}

.bg::after{
  content:"";
  position:absolute;
  inset:-10%;
  z-index:1;
  pointer-events:none;
  background:
    radial-gradient(650px 420px at var(--mx) var(--my),
      rgba(0,212,255,0.32),
      rgba(0,153,255,0.16) 35%,
      rgba(10,14,39,0.0) 70%
    ),
    radial-gradient(900px 600px at var(--mx) var(--my),
      rgba(0,212,255,0.10),
      rgba(10,14,39,0.0) 75%
    );
}

.bg span{ display:none; }

/* =========================
   CARD
   ========================= */
.card{
  position: relative;
  z-index: 5;
  width: min(1040px, 94vw);
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: 0 30px 60px rgba(0,0,0,.55), 0 0 70px var(--glow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: var(--pad);
}

.layout{
  display:grid;
  grid-template-columns: 1fr 0.9fr;
  gap: clamp(14px, 2vw, 18px);
  align-items:start;
}

.panel{ padding: 6px; }

/* BRAND */
.brand{ display:flex; align-items:center; gap: 12px; margin-bottom: 10px; }
.logo-dot{
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--tileHover1), var(--tileHover2));
  box-shadow: 0 0 18px rgba(0,212,255,.45);
}
.brand-title{ font-weight: 800; letter-spacing: .3px; line-height: 1.1; color: var(--text); }
.brand-sub{ font-size: .85em; color: var(--muted); margin-top: 2px; }

/* HEADLINE */
.headline{
  font-size: clamp(18px, 2.4vw, 22px);
  text-transform: uppercase;
  font-weight: 900;
  letter-spacing: 1px;
  line-height: 1.2;
  background: linear-gradient(135deg, var(--tileHover1), var(--tileHover2));
  -webkit-background-clip:text;
  background-clip:text;
  -webkit-text-fill-color:transparent;
}
.subtitle{
  color: var(--muted);
  font-size: 0.95em;
  line-height: 1.45;
  margin-top: 6px;
}

/* COUNTDOWN ✅ wrap biar HP rapi */
.countdown{
  display:flex;
  flex-wrap: wrap;
  align-items:stretch;
  justify-content:center;
  gap: 10px;
  margin-top: 14px;
  margin-bottom: 6px;
}

.time-box{
  flex: 1 1 76px;
  max-width: 110px;
  min-width: 74px;
  background: rgba(26,35,70,0.85);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  padding: 12px 10px;
  text-align:center;
  box-shadow: inset 0 0 0 1px rgba(0,212,255,0.08), 0 10px 25px rgba(0,0,0,0.25);
}
.time-num{ font-size: clamp(20px, 4.2vw, 28px); font-weight: 900; letter-spacing: 1px; color: var(--text); }
.time-label{ margin-top: 6px; font-size: .78em; color: var(--muted); }

.time-sep{
  display:flex;
  align-items:center;
  justify-content:center;
  color: rgba(0,212,255,0.85);
  font-weight: 900;
  margin-top: 10px;
  opacity: 0.9;
}

/* STATUS */
.status{ text-align:center; color: var(--muted); margin-top: 10px; font-size: .95em; }
.status b.open{ color: #7fffd4; }

/* BUTTON */
.btn{
  display:block;
  width: 100%;
  text-align:center;
  padding: 14px 16px;
  border-radius: 14px;
  text-decoration:none;
  color:#fff;
  font-weight: 900;
  letter-spacing: .8px;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--tileHover1), var(--tileHover2));
  box-shadow: 0 14px 30px rgba(0,212,255,.22);
  transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
  margin-top: 14px;
}
.btn:hover{ transform: translateY(-2px); box-shadow: 0 18px 40px rgba(0,212,255,.30); }
.btn:active{ transform: translateY(0); opacity: .95; }
.btn.disabled{ pointer-events:none; opacity: .45; filter: grayscale(0.2); box-shadow: none; }
.btn.pulse{ animation: pulse 1.25s ease-in-out infinite; }
@keyframes pulse{
  0%{ transform: translateY(0); box-shadow: 0 14px 30px rgba(0,212,255,.22); }
  50%{ transform: translateY(-1px); box-shadow: 0 24px 60px rgba(0,212,255,.38); }
  100%{ transform: translateY(0); box-shadow: 0 14px 30px rgba(0,212,255,.22); }
}

/* ===== GAME PANEL ===== */
.panel-game{
  border-radius: 16px;
  background: rgba(6, 12, 28, 0.35);
  border: 1px solid rgba(0,212,255,0.14);
  padding: 16px;
}

.ttt-top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.ttt-title{
  font-weight: 900;
  letter-spacing: 2px;
  font-size: 18px;
  color: rgba(255,255,255,.92);
}
.ttt-sub{
  font-size: 12px;
  color: rgba(180,210,255,.75);
  margin-top: 2px;
}

/* mode + level */
.ttt-mode{
  display:flex;
  align-items:flex-end;
  gap: 10px;
  flex-wrap: wrap;
  justify-content:flex-end;
  width: 100%;
}
.mini-label{
  font-size: 11px;
  color: rgba(180,210,255,.75);
  font-weight: 800;
  margin-bottom: 2px;
}
.select{
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 10px 34px 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(90, 140, 255, 0.18);
  background: rgba(4, 10, 24, 0.55);
  color: rgba(255,255,255,.92);
  font-weight: 800;
  cursor: pointer;
  outline: none;
}
.select:disabled{ opacity: .5; cursor: not-allowed; }
.hint{
  width: 100%;
  font-size: 11px;
  color: rgba(180,210,255,.7);
  margin-top: 2px;
}

.ttt-scores{
  display:flex;
  gap: 10px;
  margin-top: 12px;
}

.score-card{
  flex: 1;
  min-width: 78px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(4, 10, 24, 0.55);
  border: 1px solid rgba(90, 140, 255, 0.12);
  text-align:center;
}
.score-card.x{ box-shadow: 0 0 25px rgba(56,189,248,.14); }
.score-card.o{ box-shadow: 0 0 25px rgba(236,72,153,.14); }
.score-card.d{ box-shadow: 0 0 25px rgba(255,255,255,.06); }

.score-label{ font-weight: 900; font-size: 16px; }
.score-card.x .score-label{ color: #38bdf8; }
.score-card.o .score-label{ color: #ec4899; }
.score-card.d .score-label{ color: rgba(255,255,255,.7); }
.score-num{ font-weight: 900; font-size: 18px; margin-top: 2px; color: var(--text); }
.score-mini{ font-size: 11px; color: rgba(180,210,255,.65); margin-top: 2px; }

.ttt-turn{
  margin-top: 12px;
  font-size: 13px;
  color: rgba(180,210,255,.8);
  display:flex;
  align-items:center;
  gap: 8px;
  flex-wrap: wrap;
}
.turn-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: rgba(4, 10, 24, 0.55);
  border: 1px solid rgba(90, 140, 255, 0.12);
  font-weight: 900;
}
.turn-badge.x{ color:#38bdf8; box-shadow: 0 0 25px rgba(56,189,248,.12); }
.turn-badge.o{ color:#ec4899; box-shadow: 0 0 25px rgba(236,72,153,.12); }

.turn-note{
  font-size: 12px;
  color: rgba(180,210,255,.65);
  margin-left: 6px;
}

/* Board */
.ttt-board{
  position:relative;
  margin-top: 12px;
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.cell{
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  border: 1px solid rgba(90, 140, 255, 0.18);
  background: rgba(4, 10, 24, 0.55);
  cursor:pointer;
  color: rgba(255,255,255,.9);
  font-weight: 900;
  font-size: clamp(34px, 7vw, 46px);
  display:flex;
  align-items:center;
  justify-content:center;
  transition: transform .12s ease, box-shadow .12s ease;
  position: relative;
  z-index: 2;
}
.cell:hover{ transform: translateY(-1px); box-shadow: 0 0 30px rgba(0,180,255,.10); }
.cell:active{ transform: translateY(0px); opacity:.9; }
.cell.x{ color:#38bdf8; text-shadow: 0 0 18px rgba(56,189,248,.35); }
.cell.o{ color:#ec4899; text-shadow: 0 0 18px rgba(236,72,153,.35); }

.win-svg{
  position:absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events:none;
}
.win-svg line{
  stroke-width: 2.8;
  stroke-linecap: round;
  opacity: 0;
  transition: opacity .15s ease;
}

.ttt-msg{
  margin-top: 10px;
  font-size: 12px;
  color: rgba(180,210,255,.8);
  text-align:center;
}

.ttt-actions{
  margin-top: 10px;
  display:flex;
  gap: 10px;
  justify-content:center;
  flex-wrap: wrap;
}

.ttt-btn{
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(90, 140, 255, 0.18);
  background: rgba(10, 25, 60, 0.55);
  color: rgba(255,255,255,.9);
  font-weight: 800;
  cursor:pointer;
}
.ttt-btn.primary{
  background: rgba(0, 212, 255, 0.18);
  border-color: rgba(0, 212, 255, 0.28);
}

/* =========================
   MASCOT (AUTO WALK)
   ========================= */
.mascot{
  --parX: 0px;
  --parY: 0px;
  --headRot: 0deg;
  --bodyRot: 0deg;

  --mX: 84vw;
  --mY: 78vh;
  --mScale: 0.92;
  --mFlip: 1;
  --bob: 0px;

  position: fixed;
  left: var(--mX);
  top: var(--mY);
  z-index: 999;

  transform:
    translate(-50%, -50%)
    translate(var(--parX), var(--parY))
    translateY(var(--bob))
    scaleX(var(--mFlip))
    scale(var(--mScale));

  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
  -webkit-tap-highlight-color: transparent;

  filter: drop-shadow(0 18px 35px rgba(0,0,0,.40));
  will-change: transform, left, top;
}

.mascot__wrap{
  width: 220px;
  transform-origin: 50% 92%;
  animation: idle 3.2s ease-in-out infinite;
  will-change: transform;
}

.mascot__svg{ width: 100%; height: auto; display: block; pointer-events: none; }

.mascot__svg #charRoot{
  transform-box: fill-box;
  transform-origin: center 75%;
  transform: rotate(var(--bodyRot));
}
.mascot__svg #head{
  transform-box: fill-box;
  transform-origin: center 55%;
  transform: rotate(var(--headRot));
  transition: transform .08s linear;
}

/* idle / happy */
@keyframes idle{
  0%   { transform: translateY(0px) scale(1); }
  50%  { transform: translateY(-8px) scale(1.01); }
  100% { transform: translateY(0px) scale(1); }
}
@keyframes happyIdle{
  0%   { transform: translateY(0px) rotate(0deg) scale(1); }
  35%  { transform: translateY(-14px) rotate(0.8deg) scale(1.05); }
  70%  { transform: translateY(-6px) rotate(-0.8deg) scale(1.03); }
  100% { transform: translateY(0px) rotate(0deg) scale(1); }
}

.mascot.open .mascot__wrap{
  animation: happyIdle 1.15s ease-in-out infinite;
  filter: drop-shadow(0 0 18px rgba(0,212,255,.20));
}

/* WALK CYCLE: kaki & sedikit tangan */
.mascot.walking .mascot__svg #legs{
  transform-box: fill-box;
  transform-origin: center 30%;
  animation: legsSwing .42s ease-in-out infinite;
}
@keyframes legsSwing{
  0%   { transform: rotate(10deg) translateY(0px); }
  50%  { transform: rotate(-10deg) translateY(1px); }
  100% { transform: rotate(10deg) translateY(0px); }
}

.mascot.walking .mascot__svg #arms{
  transform-box: fill-box;
  transform-origin: center 20%;
  animation: armsSwing .42s ease-in-out infinite;
}
@keyframes armsSwing{
  0%   { transform: rotate(-6deg); }
  50%  { transform: rotate(6deg); }
  100% { transform: rotate(-6deg); }
}

/* tap */
.mascot.tap .mascot__wrap{ animation: tap .35s ease-out 1 !important; }
@keyframes tap{
  0%   { transform: translateY(0) scale(1); }
  35%  { transform: translateY(-7px) scale(1.06); }
  100% { transform: translateY(0) scale(1); }
}

/* bubble */
.mascot__bubble{
  position:absolute;
  left: 50%;
  top: 12px;
  transform: translate(-50%, -100%);
  max-width: min(320px, 86vw);
  padding: 10px 12px;
  border-radius: 14px;
  font-weight: 900;
  font-size: 12px;
  line-height: 1.25;
  letter-spacing: .2px;
  color: rgba(255,255,255,.95);
  background: rgba(10, 25, 60, 0.84);
  border: 1px solid rgba(0,212,255,0.22);
  box-shadow: 0 18px 45px rgba(0,0,0,.35);
  opacity: 0;
  pointer-events:none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.mascot__bubble::after{
  content:"";
  position:absolute;
  left: 50%;
  bottom: -8px;
  transform: translateX(-50%) rotate(45deg);
  width: 14px;
  height: 14px;
  background: rgba(10, 25, 60, 0.84);
  border-right: 1px solid rgba(0,212,255,0.20);
  border-bottom: 1px solid rgba(0,212,255,0.20);
  border-bottom-right-radius: 3px;
}
.mascot.open .mascot__bubble{ border-color: rgba(34,211,238,.30); }
.mascot.talk .mascot__bubble{
  opacity: 1;
  animation: bubblePop 2.3s ease-out 1;
}
@keyframes bubblePop{
  0%   { transform: translate(-50%, -92%) scale(.92); opacity: 0; }
  10%  { opacity: 1; }
  70%  { transform: translate(-50%, -112%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -120%) scale(1); opacity: 0; }
}

.mascot__hint{
  margin-top: 6px;
  text-align:center;
  font-size: 11px;
  font-weight: 900;
  color: rgba(180,210,255,.75);
  opacity: .85;
  pointer-events:none;
}

/* blink */
.lid{
  animation: blink 4.6s infinite;
  transform-origin: center;
}
@keyframes blink{
  0%, 95%, 100% { opacity: 1; }
  96% { opacity: 0.06; }
  97% { opacity: 1; }
}

/* =========================
   RESPONSIVE
   ========================= */
@media (max-width: 980px){
  .layout{ grid-template-columns: 1fr; }
  .panel{ padding: 2px; }
  .panel-game{ padding: 14px; }
  .time-sep{ display:none; }
  .mascot__wrap{ width: 190px; }
}

@media (max-width: 600px){
  .card{ width: min(520px, 94vw); padding: 16px; }
  .subtitle{ font-size: 0.9em; }
  .ttt-scores{ gap: 8px; }
  .score-card{ padding: 9px; }
  .mascot__wrap{ width: 160px; }
  .mascot__hint{ display:none; }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce){
  .mascot__wrap{ animation: none !important; }
  .btn.pulse{ animation: none !important; }
  .mascot.walking .mascot__svg #legs,
  .mascot.walking .mascot__svg #arms{
    animation: none !important;
  }
}

