:root{
  --bg:#070A1A;
  --panel:#101A3A;

  --wall:#061029;
  --path:#182B66;

  --start:#18c16e;
  --goal:#ffbf2f;

  --player:#ff4fd8;

  --text:#f3f6ff;
  --muted:#b8c5ff;

  --shadow: 0 16px 40px rgba(0,0,0,.45);
  --radius:22px;

  --tileSize: 52px;
  --tileGap: 3px;
}

*{box-sizing:border-box;}

body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background:
    radial-gradient(1200px 700px at 20% 0%, #2b5dff25, transparent),
    radial-gradient(900px 600px at 80% 20%, #ff4fd820, transparent),
    var(--bg);
  color:var(--text);
}

.confetti{
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.app{
  max-width: 980px;
  margin: 0 auto;
  padding: 18px 14px 28px;
  display:grid;
  gap:16px;
}

.topbar{
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display:flex;
  align-items:center;
  justify-content:space-between;
  border: 1px solid rgba(255,255,255,.10);
  backdrop-filter: blur(6px);
}
.topbar h1{margin:0; font-size: 20px;}
.hud{display:flex; gap:14px; color:var(--muted); font-size: 14px;}

.boardWrap{
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  overflow:auto;
  border: 1px solid rgba(255,255,255,.10);

  /* ✅ center the maze so it doesn’t look empty on the right */
  display:flex;
  justify-content:center;
}

.board{
  display:grid;
  gap: var(--tileGap);
  justify-content:start;
  user-select:none;
  padding: 10px;
  border-radius: 18px;
  width: fit-content;
  background:
    radial-gradient(circle at 30% 10%, #2b5dff22, transparent 45%),
    radial-gradient(circle at 80% 40%, #ff4fd822, transparent 40%),
    rgba(0,0,0,.15);
}

.tile{
  width: var(--tileSize);
  height: var(--tileSize);
  border-radius: 14px;
  position:relative;
  background: rgba(255,255,255,.06);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
}

/* Maze colors */
.wall{
  background: linear-gradient(180deg, #02061a, #0a0f2e);
}
.path{
  background: linear-gradient(180deg,#3a6cff,#1e3caa);
}
.start{
  background: linear-gradient(180deg,#2cff9a,#18c16e);
}

/* ✅ finish line goal */
.goal{
  background:
    repeating-linear-gradient(
      45deg,
      #ffffff 0 10px,
      #0a0f2e 10px 20px
    );
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.25);
}

/* Player shows avatar + name */
.player::after{
  content: attr(data-avatar);
  position:absolute;
  inset: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--player) 65%, white);
  display:grid;
  place-items:center;
  font-size: calc(var(--tileSize) * 0.42);
  box-shadow: 0 0 0 4px rgba(0,0,0,.25), 0 14px 24px rgba(0,0,0,.35);
}

.player::before{
  content: attr(data-name);
  position:absolute;
  left: 50%;
  bottom: -10px;
  transform: translateX(-50%);
  background: rgba(0,0,0,.55);
  border: 1px solid rgba(255,255,255,.14);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
}

.controls{
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display:grid;
  justify-items:center;
  gap:10px;
  border: 1px solid rgba(255,255,255,.10);
}

.game-hidden{ display:none; }

.row{display:flex; gap:10px; align-items:center;}

.btn{
  border:0;
  background:#22306a;
  color:var(--text);
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 16px;
  cursor:pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
}
.btn:hover{filter:brightness(1.08);}
.btn:active{transform:translateY(1px);}

.primary{background:#2b5dff;}
.subtle{background:transparent; border:1px solid #2a366a; color:var(--muted); box-shadow:none;}

.hint{margin:0; color:var(--muted); font-size: 13px; text-align:center;}

.backdrop{
  position:fixed; inset:0;
  display:grid; place-items:center;
  background: rgba(0,0,0,.55);
  padding: 18px;
}

.hidden{display:none;}

.modal{
  width:min(560px, 100%);
  background: #0f1734;  /* solid panel instead of glass */
  border-radius: 22px;
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.12);
}

.modal h2{margin:0 0 10px; font-size: 24px;}
.feedback{min-height: 22px; margin: 8px 2px 0; color: var(--muted);}

.label{
  display:block;
  margin: 12px 0 6px;
  color: var(--text);
  font-weight: 600;
}

.answerRow{
  display:flex;
  gap:10px;
  align-items:center;
}

#answerInput,
#nameInput{
  width: 100%;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid #2a366a;
  outline:none;
  background:#0f1734;
  color:var(--text);
  font-size: 16px;
}

.modalActions{
  display:flex;
  justify-content:flex-end;
  margin-top: 14px;
}

/* Rules box */
.rulesBox{
  margin: 10px 0 8px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.18);
}
.rulesBox ul{
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
}
.miniBtns{ display:flex; gap:8px; flex-wrap:wrap; }
.miniBtn{
  display:inline-grid;
  place-items:center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background:#22306a;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
}

/* Avatar picker */
.avatarPicker{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.avatarBtn{
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  padding: 12px 14px;
  border-radius: 16px;
  cursor:pointer;
  font-size: 24px;
}
.avatarBtn.selected{
  outline: 3px solid rgba(43,93,255,.9);
  background: rgba(43,93,255,.18);
}

.toast{
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  background: #0f1734;
  border: 1px solid #2a366a;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow);
}

/* 📱 Mobile tweaks */
@media (max-width: 520px){
  :root{
    --tileSize: 40px;   /* smaller tiles on phones */
    --tileGap: 2px;
  }

  .app{
    padding: 12px 10px 18px;
    gap: 12px;
  }

  .topbar h1{ font-size: 18px; }
  .hud{ font-size: 13px; }

  .modal{
    width: min(520px, 100%);
    padding: 16px;
  }

  .player::before{
    font-size: 10px;
    bottom: -9px;
  }
}

/* Prevent the page from scrolling when swiping on the game */
body{
  overscroll-behavior: none;
}

.boardWrap{
  touch-action: none;  /* important for swipe controls */
}

/* Mobile D-pad */
.mobileControls{
  display:none;
  justify-items:center;
  gap:10px;
  padding: 10px 0 0;
}

.mRow{ display:flex; gap:10px; }

.mBtn{
  border:0;
  background:#22306a;
  color:var(--text);
  width: 56px;
  height: 56px;
  border-radius: 16px;
  font-size: 22px;
  cursor:pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
}

@media (max-width: 520px){
  .mobileControls{ display:grid; }
}
