/* ============ ネオンブロックス NEON BLOCKS ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --cyan: #00f0ff;
  --purple: #b967ff;
  --pink: #ff2e63;
  --yellow: #ffd500;
  --green: #00ff9f;
  --bg-deep: #05060f;
  --panel-bg: rgba(10, 14, 32, 0.72);
  --panel-border: rgba(0, 240, 255, 0.28);
  --text: #d8ecff;
  --text-dim: #6d7fa3;
  --font: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", "Meiryo", "Noto Sans JP", system-ui, sans-serif;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  font-family: var(--font);
  color: var(--text);
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#bg-canvas {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
}

#app {
  position: fixed; inset: 0;
  z-index: 1;
  display: flex; align-items: center; justify-content: center;
}

/* ============ ゲーム画面レイアウト ============ */
#game-scale {
  transform-origin: center center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}

#game-container {
  display: flex; align-items: flex-start; gap: 20px;
}

.side-panel {
  display: flex; flex-direction: column; gap: 14px;
  width: 148px;
  padding-top: 32px;
}

.panel-box {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.08), inset 0 0 24px rgba(0, 240, 255, 0.04);
  backdrop-filter: blur(4px);
}

.panel-title {
  font-size: 12px; letter-spacing: 3px;
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.6);
  margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: center;
}
.key-hint {
  font-size: 10px; color: var(--text-dim);
  border: 1px solid rgba(109, 127, 163, 0.5);
  border-radius: 4px; padding: 0 5px; letter-spacing: 0;
}

#hold-canvas, #next-canvas { display: block; margin: 0 auto; }

.stats-box .stat-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 3px 0;
}
.stat-label { font-size: 11px; color: var(--text-dim); letter-spacing: 2px; }
.stat-value {
  font-size: 17px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff; text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}
.stat-value.dim { color: var(--text-dim); text-shadow: none; font-size: 14px; }

.combo-box {
  text-align: center;
  opacity: 0; transform: scale(0.85);
  transition: opacity 0.25s, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-color: rgba(255, 213, 0, 0.4);
}
.combo-box.active { opacity: 1; transform: scale(1); }
.combo-num {
  font-size: 34px; font-weight: 800;
  color: var(--yellow);
  text-shadow: 0 0 16px rgba(255, 213, 0, 0.8);
  line-height: 1;
}
.combo-label { font-size: 11px; letter-spacing: 4px; color: var(--text-dim); margin-top: 4px; }

.mode-box .mode-name { font-size: 16px; font-weight: 700; color: #fff; }
.mode-box .mode-goal { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.icon-btn {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  color: var(--text);
  font-size: 18px;
  padding: 8px 0;
  cursor: pointer;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.icon-btn:hover { border-color: var(--cyan); box-shadow: 0 0 14px rgba(0, 240, 255, 0.35); }

/* ============ 盤面 ============ */
#board-wrap {
  position: relative;
  width: 320px; height: 672px;
  will-change: transform;
}
#board-canvas {
  display: block;
  border: 1px solid rgba(0, 240, 255, 0.35);
  border-radius: 6px;
  background: rgba(4, 6, 18, 0.82);
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.12), 0 0 80px rgba(185, 103, 255, 0.08),
              inset 0 0 40px rgba(0, 20, 50, 0.55);
}
#fx-canvas {
  position: absolute; left: -80px; top: -80px;
  pointer-events: none;
  z-index: 5;
}
#touch-area { position: absolute; inset: 0; z-index: 6; }

#announce {
  position: absolute; left: 50%; top: 34%;
  transform: translate(-50%, -50%);
  font-size: 34px; font-weight: 900; letter-spacing: 3px;
  white-space: nowrap;
  text-align: center;
  pointer-events: none; z-index: 8;
  opacity: 0;
}
#announce.pop { animation: announcePop 1.3s ease-out forwards; }
#announce.c-cyan   { color: var(--cyan);   text-shadow: 0 0 18px var(--cyan), 0 0 50px rgba(0,240,255,.6); }
#announce.c-purple { color: var(--purple); text-shadow: 0 0 18px var(--purple), 0 0 50px rgba(185,103,255,.6); }
#announce.c-gold   { color: var(--yellow); text-shadow: 0 0 18px var(--yellow), 0 0 50px rgba(255,213,0,.6); }
#announce.c-white  { color: #fff;          text-shadow: 0 0 18px #fff, 0 0 50px rgba(255,255,255,.6); }
@keyframes announcePop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(1.6); }
  12%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  75%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -56%) scale(0.94); }
}

#announce-sub {
  position: absolute; left: 50%; top: 44%;
  transform: translate(-50%, -50%);
  font-size: 16px; font-weight: 700; letter-spacing: 2px;
  color: var(--green); text-shadow: 0 0 12px rgba(0,255,159,.7);
  white-space: nowrap; pointer-events: none; z-index: 8;
  opacity: 0;
}
#announce-sub.pop { animation: announcePop 1.3s ease-out forwards; }

#countdown {
  position: absolute; left: 50%; top: 42%;
  transform: translate(-50%, -50%);
  font-size: 88px; font-weight: 900;
  color: #fff; text-shadow: 0 0 30px var(--cyan), 0 0 80px var(--cyan);
  pointer-events: none; z-index: 9;
  display: none;
}
#countdown.tick { display: block; animation: cdPop 0.5s ease-out; }
@keyframes cdPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.8); }
  30% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0.9; transform: translate(-50%, -50%) scale(0.96); }
}

#hint-bar {
  position: absolute; left: 50%; bottom: 12px;
  transform: translateX(-50%);
  font-size: 12px; color: var(--text-dim);
  background: rgba(5, 8, 20, 0.8);
  border: 1px solid rgba(109, 127, 163, 0.3);
  border-radius: 20px;
  padding: 6px 14px;
  white-space: nowrap;
  pointer-events: none; z-index: 7;
  opacity: 0; transition: opacity 0.6s;
}
#hint-bar.show { opacity: 1; }

/* ============ タッチ操作ボタン ============ */
#touch-bar { display: none; gap: 12px; }
body.touch-mode #touch-bar { display: flex; }
.touch-btn {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  color: var(--text);
  font-size: 18px; font-weight: 700;
  padding: 12px 26px;
  cursor: pointer;
}
.touch-btn:active { background: rgba(0, 240, 255, 0.2); }

/* ============ 全画面パルス ============ */
#pulse { position: fixed; inset: 0; pointer-events: none; z-index: 40; opacity: 0; }
#pulse.pulse-cyan { animation: pulseAnim 0.6s ease-out; background: radial-gradient(circle at center, rgba(0,240,255,0.28), rgba(0,240,255,0.04) 60%, transparent 80%); }
#pulse.pulse-purple { animation: pulseAnim 0.6s ease-out; background: radial-gradient(circle at center, rgba(185,103,255,0.3), rgba(185,103,255,0.05) 60%, transparent 80%); }
#pulse.pulse-gold { animation: pulseAnim 0.8s ease-out; background: radial-gradient(circle at center, rgba(255,213,0,0.3), rgba(255,213,0,0.05) 60%, transparent 80%); }
@keyframes pulseAnim { 0% { opacity: 0; } 15% { opacity: 1; } 100% { opacity: 0; } }

/* ============ オーバーレイ画面 ============ */
.screen {
  position: fixed; inset: 0;
  z-index: 50;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(3, 5, 14, 0.82);
  backdrop-filter: blur(6px);
  overflow-y: auto;
}
.screen.visible { display: flex; }

.screen-inner {
  max-width: 720px;
  width: 92%;
  max-height: 94vh;
  overflow-y: auto;
  text-align: center;
  padding: 30px 20px;
  animation: screenIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes screenIn {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
.small-inner { max-width: 380px; }

.logo {
  font-size: 72px; font-weight: 900; letter-spacing: 10px;
  background: linear-gradient(120deg, var(--cyan) 10%, var(--purple) 50%, var(--pink) 90%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  filter: drop-shadow(0 0 24px rgba(0, 240, 255, 0.45));
  margin-bottom: 4px;
}
.logo-sub {
  font-size: 15px; letter-spacing: 14px;
  color: var(--text-dim);
  margin-bottom: 40px;
}

.title-btns, .col-btns { display: flex; flex-direction: column; gap: 14px; align-items: center; margin-bottom: 30px; }
.row-btns { display: flex; gap: 14px; justify-content: center; margin-top: 26px; }

.btn {
  font-family: var(--font);
  font-size: 17px; font-weight: 700; letter-spacing: 3px;
  color: var(--text);
  background: rgba(10, 16, 36, 0.85);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 13px 0;
  width: 250px;
  cursor: pointer;
  transition: all 0.18s;
}
.btn:hover {
  border-color: var(--cyan);
  color: #fff;
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.35);
  transform: translateY(-2px);
}
.btn:active { transform: translateY(0); }
.btn-primary {
  border-color: var(--cyan);
  background: linear-gradient(120deg, rgba(0, 240, 255, 0.18), rgba(185, 103, 255, 0.18));
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.25);
  color: #fff;
}
.btn-back { width: 180px; margin-top: 24px; }

.howto {
  margin: 0 auto; max-width: 520px;
  background: var(--panel-bg);
  border: 1px solid rgba(109, 127, 163, 0.25);
  border-radius: 12px;
  padding: 18px 22px;
  text-align: left;
}
.howto-title { font-size: 13px; letter-spacing: 4px; color: var(--cyan); margin-bottom: 8px; }
.howto p { font-size: 13px; line-height: 1.8; color: var(--text-dim); margin-bottom: 12px; }
.howto-keys { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12px; color: var(--text-dim); }
.howto-keys b { color: var(--text); }

.screen-title {
  font-size: 34px; font-weight: 900; letter-spacing: 8px;
  color: #fff; text-shadow: 0 0 20px rgba(0, 240, 255, 0.5);
  margin-bottom: 26px;
}

/* ============ モード選択 ============ */
.mode-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  max-width: 640px; margin: 0 auto;
}
.mode-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 20px 18px 16px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.mode-card:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 24px rgba(0, 240, 255, 0.3);
  transform: translateY(-3px);
}
.mode-icon { font-size: 30px; margin-bottom: 8px; }
.mode-card-name { font-size: 19px; font-weight: 800; letter-spacing: 2px; color: #fff; margin-bottom: 6px; }
.mode-card-desc { font-size: 12px; line-height: 1.6; color: var(--text-dim); min-height: 38px; }
.mode-stars { font-size: 15px; letter-spacing: 3px; color: var(--yellow); min-height: 20px; margin-top: 6px; text-shadow: 0 0 8px rgba(255,213,0,.5); }
.s-on { color: var(--yellow); }
.s-off { color: rgba(109, 127, 163, 0.45); text-shadow: none; }
.mode-best { font-size: 12px; color: var(--cyan); margin-top: 4px; }

/* ============ リザルト ============ */
.result-mode { font-size: 14px; letter-spacing: 4px; color: var(--text-dim); margin-bottom: 8px; }
.result-stars { font-size: 30px; letter-spacing: 6px; color: var(--yellow); text-shadow: 0 0 14px rgba(255,213,0,.6); min-height: 40px; }
.result-score-row { display: flex; align-items: baseline; justify-content: center; gap: 14px; }
.result-score {
  font-size: 56px; font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #fff; text-shadow: 0 0 24px rgba(0, 240, 255, 0.6);
}
.result-new {
  display: none;
  font-size: 15px; font-weight: 800; color: var(--pink);
  text-shadow: 0 0 10px rgba(255, 46, 99, 0.8);
  animation: newBlink 0.8s ease-in-out infinite alternate;
}
.result-new.show { display: block; }
@keyframes newBlink { from { opacity: 0.55; } to { opacity: 1; } }
.result-best { font-size: 13px; color: var(--text-dim); margin: 6px 0 20px; }

.result-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  max-width: 560px; margin: 0 auto;
}
.rstat {
  background: var(--panel-bg);
  border: 1px solid rgba(109, 127, 163, 0.25);
  border-radius: 10px;
  padding: 12px 6px;
}
.rstat-v { font-size: 22px; font-weight: 800; color: var(--cyan); font-variant-numeric: tabular-nums; text-shadow: 0 0 10px rgba(0,240,255,.4); }
.rstat-l { font-size: 11px; color: var(--text-dim); margin-top: 4px; letter-spacing: 1px; }

/* ============ 設定 ============ */
.settings-list { max-width: 420px; margin: 0 auto 24px; }
.setting-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--panel-bg);
  border: 1px solid rgba(109, 127, 163, 0.25);
  border-radius: 10px;
  padding: 13px 18px;
  margin-bottom: 10px;
  font-size: 15px;
  cursor: pointer;
}
.setting-row input { display: none; }
.switch {
  width: 46px; height: 24px;
  border-radius: 12px;
  background: rgba(109, 127, 163, 0.35);
  position: relative;
  transition: background 0.2s;
}
.switch::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #8fa3c8;
  transition: all 0.2s;
}
.setting-row input:checked + .switch { background: rgba(0, 240, 255, 0.35); }
.setting-row input:checked + .switch::after { left: 25px; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }

.keys-table {
  max-width: 420px; margin: 0 auto;
  background: var(--panel-bg);
  border: 1px solid rgba(109, 127, 163, 0.25);
  border-radius: 12px;
  padding: 16px 20px;
  text-align: left;
}
.keys-title { font-size: 13px; letter-spacing: 4px; color: var(--cyan); margin-bottom: 10px; }
.key-row {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 13px; color: var(--text-dim);
  padding: 5px 0;
  border-bottom: 1px solid rgba(109, 127, 163, 0.12);
}
.key-row:last-child { border-bottom: none; }
.key-row b { color: var(--text); text-align: right; }

/* ============ 実績 ============ */
.achv-progress { font-size: 14px; color: var(--cyan); margin-bottom: 18px; letter-spacing: 2px; }
#achv-list {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  max-width: 640px; margin: 0 auto;
  text-align: left;
}
.achv-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel-bg);
  border: 1px solid rgba(109, 127, 163, 0.22);
  border-radius: 10px;
  padding: 10px 14px;
  opacity: 0.45;
}
.achv-item.unlocked { opacity: 1; border-color: rgba(255, 213, 0, 0.45); box-shadow: 0 0 12px rgba(255, 213, 0, 0.12); }
.achv-icon { font-size: 22px; }
.achv-name { font-size: 14px; font-weight: 700; color: #fff; }
.achv-item.unlocked .achv-name { color: var(--yellow); }
.achv-desc { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* ============ 実績トースト ============ */
#toast-wrap {
  position: fixed; top: 20px; right: 20px;
  z-index: 90;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  background: rgba(12, 16, 36, 0.95);
  border: 1px solid rgba(255, 213, 0, 0.55);
  border-radius: 12px;
  padding: 12px 18px;
  box-shadow: 0 0 22px rgba(255, 213, 0, 0.25);
  animation: toastIn 0.4s cubic-bezier(0.22, 1, 0.36, 1), toastOut 0.4s ease-in 3.2s forwards;
}
.toast-icon { font-size: 24px; }
.toast-title { font-size: 12px; color: var(--yellow); letter-spacing: 2px; }
.toast-name { font-size: 15px; font-weight: 800; color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateX(60px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(60px); } }

/* ============ スクロールバー ============ */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 240, 255, 0.25); border-radius: 4px; }

@media (max-width: 640px) {
  .mode-grid, #achv-list { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
  .logo { font-size: 48px; letter-spacing: 6px; }
}

/* ---------- KanaWorks_AI クレジット ---------- */
.kw-credit {
  display: inline-flex; align-items: center; gap: 9px;
  margin-top: 18px; padding: 6px 16px 6px 8px;
  background: rgba(5, 6, 15, 0.6);
  border: 1px solid rgba(0, 240, 255, 0.28);
  border-radius: 999px;
  text-decoration: none;
  color: #8a93c0; font-size: 12.5px;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.kw-credit img { width: 28px; height: 28px; display: block; }
.kw-credit b { color: var(--cyan); }
.kw-credit:hover {
  transform: translateY(-2px);
  border-color: var(--cyan);
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.3);
}
