:root{
  --bg-0:#05070f;
  --bg-1:#0b0f1e;
  --panel:#11162a;
  --panel-line:rgba(255,255,255,.08);
  --text:#eef1fb;
  --text-dim:#8b93b8;
  --accent:#6ee7ff;
  --accent-2:#a78bfa;
  --go:#22e07a;
  --go-glow:#4dffa8;
  --bad:#ff5d7a;
  --warn:#ffcf5c;
  --radius:18px;
  font-family:"Noto Sans JP","Rajdhani",sans-serif;
}

*{box-sizing:border-box; -webkit-tap-highlight-color:transparent;}
html,body{height:100%;}
body{
  margin:0;
  background:var(--bg-0);
  color:var(--text);
  min-height:100vh;
  display:flex;
  flex-direction:column;
  overflow-x:hidden;
  user-select:none;
}

.bg-glow{
  position:fixed; inset:0; z-index:-1;
  background:
    radial-gradient(600px 400px at 15% 0%, rgba(110,231,255,.14), transparent 60%),
    radial-gradient(700px 500px at 90% 100%, rgba(167,139,250,.16), transparent 60%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1));
}

.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:16px 20px;
  max-width:720px; width:100%; margin:0 auto;
}
.topbar h1{
  font-size:20px; margin:0; display:flex; align-items:center; gap:6px;
  letter-spacing:.02em;
}
.topbar-btns{ display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end; }
.logo-bolt{ filter:drop-shadow(0 0 8px var(--accent)); }
.logo-deluxe{
  font-family:"Rajdhani",sans-serif; font-weight:700; margin-left:4px;
  background:linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip:text; background-clip:text; color:transparent;
  font-size:16px; letter-spacing:.08em;
}

.icon-btn{
  background:var(--panel);
  border:1px solid var(--panel-line);
  color:var(--text);
  padding:8px 14px;
  border-radius:12px;
  font-size:14px;
  cursor:pointer;
  transition:.15s;
}
.icon-btn:hover{ border-color:var(--accent); color:var(--accent); }

.stage{
  flex:1;
  max-width:720px; width:100%; margin:0 auto;
  padding:8px 20px 40px;
  display:flex; flex-direction:column;
}

.panel{
  display:flex; flex-direction:column; align-items:center;
  text-align:center;
  gap:18px;
  padding:24px 8px;
}

.lead{ font-size:17px; line-height:1.6; color:var(--text); margin:8px 0 0; }
.hint{ font-size:13px; color:var(--text-dim); margin-top:4px; }

.best-row{ display:flex; gap:14px; flex-wrap:wrap; justify-content:center; }
.best-chip{
  background:var(--panel);
  border:1px solid var(--panel-line);
  border-radius:14px;
  padding:12px 20px;
  display:flex; flex-direction:column; gap:4px; min-width:150px;
}
.best-label{ font-size:12px; color:var(--text-dim); }
.best-value{ font-family:"Rajdhani",sans-serif; font-size:26px; font-weight:700; color:var(--accent); }

.btn{
  border:none; cursor:pointer;
  border-radius:14px;
  font-family:"Noto Sans JP",sans-serif;
  font-weight:700;
  transition:.15s transform,.15s box-shadow,.15s filter;
}
.btn:active{ transform:scale(.96); }
.btn-primary{
  background:linear-gradient(135deg, var(--accent), var(--accent-2));
  color:#05070f;
  box-shadow:0 8px 24px rgba(110,231,255,.25);
}
.btn-primary:hover{ filter:brightness(1.08); }
.btn-huge{ padding:18px 48px; font-size:20px; }
.btn-ghost{
  background:transparent;
  border:1px solid var(--panel-line);
  color:var(--text);
  padding:14px 28px;
  font-size:16px;
}
.btn-ghost:hover{ border-color:var(--accent); color:var(--accent); }
.btn-row{ display:flex; gap:12px; flex-wrap:wrap; justify-content:center; }

/* ---- Board ---- */
.panel-board{ padding:8px; gap:14px; }
.round-indicator{ display:flex; gap:10px; }
.round-dot{
  width:12px; height:12px; border-radius:50%;
  background:var(--panel);
  border:2px solid var(--panel-line);
  transition:.2s;
}
.round-dot.done{ background:var(--accent); border-color:var(--accent); }
.round-dot.active{ border-color:var(--accent-2); box-shadow:0 0 10px var(--accent-2); }

.board{
  width:100%;
  aspect-ratio:16/11;
  max-height:60vh;
  border-radius:24px;
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:10px;
  cursor:pointer;
  transition:background .08s linear;
  background:#3a1620;
  border:2px solid rgba(255,93,122,.35);
  box-shadow:inset 0 0 60px rgba(0,0,0,.3);
}
.board.state-ready{ background:#3a1620; border-color:rgba(255,93,122,.35); }
.board.state-go{
  background:linear-gradient(160deg,#0f5b34,var(--go));
  border-color:var(--go-glow);
  box-shadow:0 0 60px rgba(34,224,122,.45), inset 0 0 60px rgba(0,0,0,.15);
}
.board.state-early{
  background:linear-gradient(160deg,#5b0f1f,var(--bad));
  border-color:var(--bad);
}
.board.state-tapped{
  background:linear-gradient(160deg,#123a5b,var(--accent));
  border-color:var(--accent);
}

.board-text{
  font-family:"Rajdhani",sans-serif;
  font-size:38px; font-weight:700; color:#fff;
  text-shadow:0 2px 10px rgba(0,0,0,.35);
}
.board-sub{ font-size:14px; color:rgba(255,255,255,.85); }

/* ---- Result ---- */
.rank-emoji{ font-size:56px; line-height:1; filter:drop-shadow(0 0 20px rgba(110,231,255,.4)); }
.rank-title{
  font-family:"Rajdhani",sans-serif;
  font-size:30px; margin:0;
  background:linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip:text; background-clip:text; color:transparent;
}

.result-grid{ display:flex; gap:12px; flex-wrap:wrap; justify-content:center; width:100%; }
.result-card{
  flex:1; min-width:110px;
  background:var(--panel);
  border:1px solid var(--panel-line);
  border-radius:14px;
  padding:14px;
  display:flex; flex-direction:column; gap:6px;
}
.result-label{ font-size:12px; color:var(--text-dim); }
.result-value{ font-family:"Rajdhani",sans-serif; font-size:24px; font-weight:700; }

.round-times{
  display:flex; gap:8px; flex-wrap:wrap; justify-content:center;
}
.round-time-chip{
  font-family:"Rajdhani",sans-serif;
  font-size:13px; font-weight:600;
  background:var(--panel);
  border:1px solid var(--panel-line);
  border-radius:10px;
  padding:6px 10px;
  color:var(--text-dim);
}
.round-time-chip.fail{ color:var(--bad); border-color:rgba(255,93,122,.4); }

.new-record{
  color:var(--warn);
  font-weight:700;
  animation:pop .5s ease;
}
@keyframes pop{ 0%{transform:scale(.7); opacity:0;} 60%{transform:scale(1.1);} 100%{transform:scale(1); opacity:1;} }

/* ---- World ranking submit box ---- */
.submit-box{
  width:100%;
  background:var(--panel);
  border:1px solid var(--panel-line);
  border-radius:16px;
  padding:16px;
  display:flex; flex-direction:column; gap:10px; align-items:center;
}
.submit-label{ margin:0; font-size:14px; color:var(--text-dim); }
.submit-row{ display:flex; gap:8px; width:100%; max-width:340px; }
.submit-input{
  flex:1; min-width:0;
  background:var(--bg-1);
  border:1px solid var(--panel-line);
  border-radius:10px;
  padding:10px 12px;
  color:var(--text);
  font-size:14px;
}
.submit-input:focus{ outline:none; border-color:var(--accent); }
.submit-row .btn{ padding:10px 18px; font-size:14px; white-space:nowrap; }
.submit-status{ margin:0; font-size:13px; color:var(--text-dim); min-height:1.2em; }
.submit-status.ok{ color:var(--go); }
.submit-status.error{ color:var(--bad); }

/* ---- World ranking list ---- */
.world-rank-row{
  display:grid;
  grid-template-columns:28px 1fr auto auto auto;
  gap:8px;
  align-items:center;
  padding:10px 0;
  border-bottom:1px solid var(--panel-line);
  font-size:14px;
}
.world-rank-row:last-child{ border-bottom:none; }
.world-rank-row.me{ background:rgba(110,231,255,.08); border-radius:10px; padding-left:8px; padding-right:8px; }
.world-rank-pos{ color:var(--text-dim); font-family:"Rajdhani",sans-serif; font-weight:700; }
.world-rank-name{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.world-rank-avg{ font-family:"Rajdhani",sans-serif; font-weight:700; color:var(--accent); }
.world-rank-best{ font-family:"Rajdhani",sans-serif; font-size:12px; color:var(--text-dim); }
.replay-btn{ padding:6px 10px; font-size:13px; line-height:1; }

/* ---- Achievements ---- */
.ach-progress{
  font-size:13px; color:var(--text-dim);
  margin:0 0 12px;
  font-family:"Rajdhani",sans-serif; font-weight:700;
}
.ach-row{
  display:flex; align-items:center; gap:12px;
  padding:10px 0;
  border-bottom:1px solid var(--panel-line);
}
.ach-row:last-child{ border-bottom:none; }
.ach-emoji{ font-size:22px; width:30px; text-align:center; flex-shrink:0; }
.ach-text{ display:flex; flex-direction:column; gap:2px; }
.ach-title{ margin:0; font-size:14px; font-weight:700; color:var(--text); }
.ach-desc{ margin:0; font-size:12px; color:var(--text-dim); }
.ach-row.locked .ach-title,
.ach-row.locked .ach-desc{ color:var(--text-dim); opacity:.6; }
.ach-row.locked .ach-emoji{ opacity:.5; }
.ach-row.unlocked .ach-title{ color:var(--accent); }

/* ---- Replay mini board ---- */
.board-mini{
  max-height:220px;
  aspect-ratio:16/9;
}

/* ---- Achievement toast ---- */
.achievement-toast{
  position:fixed;
  right:20px; bottom:20px;
  z-index:70;
  display:flex; align-items:center; gap:12px;
  background:var(--panel);
  border:1px solid var(--accent);
  box-shadow:0 8px 30px rgba(110,231,255,.25);
  border-radius:14px;
  padding:14px 18px;
  max-width:280px;
  transform:translateY(140%);
  opacity:0;
  transition:transform .35s cubic-bezier(.2,.9,.3,1.3), opacity .35s ease;
  pointer-events:none;
}
.achievement-toast.show{ transform:translateY(0); opacity:1; }
.achievement-toast .toast-emoji{ font-size:28px; flex-shrink:0; }
.achievement-toast .toast-title{ margin:0; font-size:11px; color:var(--text-dim); text-transform:uppercase; letter-spacing:.05em; }
.achievement-toast .toast-name{ margin:2px 0 0; font-size:15px; font-weight:700; color:var(--accent); }

/* ---- Flash message ---- */
.flash-msg{
  position:fixed;
  top:20px; left:50%;
  transform:translate(-50%,-140%);
  background:var(--panel);
  border:1px solid var(--panel-line);
  padding:12px 22px;
  border-radius:12px;
  font-weight:700;
  z-index:50;
  transition:transform .25s ease;
  pointer-events:none;
}
.flash-msg.show{ transform:translate(-50%,0); }

/* ---- Modal ---- */
.modal-overlay{
  position:fixed; inset:0; z-index:60;
  background:rgba(2,4,10,.65);
  align-items:center; justify-content:center;
  padding:20px;
  backdrop-filter:blur(4px);
}
.modal-overlay[hidden]{ display:none; }
.modal-overlay:not([hidden]){ display:flex; }
.modal{
  background:var(--bg-1);
  border:1px solid var(--panel-line);
  border-radius:20px;
  max-width:480px; width:100%;
  max-height:80vh;
  display:flex; flex-direction:column;
  overflow:hidden;
}
.modal-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:16px 20px;
  border-bottom:1px solid var(--panel-line);
}
.modal-head h3{ margin:0; font-size:16px; }
.modal-body{ padding:16px 20px; overflow-y:auto; }
.modal-body:last-child{ border-top:1px solid var(--panel-line); }

.history-row{
  display:flex; justify-content:space-between; align-items:center;
  padding:10px 0;
  border-bottom:1px solid var(--panel-line);
  font-size:14px;
}
.history-row:last-child{ border-bottom:none; }
.history-rank{ color:var(--text-dim); width:28px; }
.history-avg{ font-family:"Rajdhani",sans-serif; font-weight:700; color:var(--accent); }
.history-date{ color:var(--text-dim); font-size:12px; }
.empty-msg{ color:var(--text-dim); font-size:14px; text-align:center; padding:20px 0; }

.changelog-title{ font-size:12px; color:var(--text-dim); margin:0 0 8px; }
.changelog-item{ font-size:13px; color:var(--text-dim); margin:4px 0; }
.changelog-item b{ color:var(--text); }

.footer{
  text-align:center;
  padding:16px;
  color:var(--text-dim);
  font-size:12px;
}

@media (max-width:480px){
  .board-text{ font-size:30px; }
  .topbar h1{ font-size:17px; }
  .btn-huge{ padding:16px 36px; font-size:18px; }
}
