/* ============================================================
   ネトの金庫を開けろ！ ── Activity版スタイル
   コンセプト: メイプルの黄金の金庫に、後付けの「解錠デバイス
   (緑CRT端末)」をボルト留めした、という世界観。
   palette:
     --sand-900 #1C1209  神殿の闇      --sand-700 #33220F 砂岩
     --gold-500 #E8B23A  金庫の金      --gold-700 #A9741C 金の陰
     --key-brown #6E4526 キーパッド    --cream   #FFEFCF 文字
     --crt #5CFF95 端末緑  --cyan #5CD9FF ▲  --alert #FF5D5D 封鎖
   ============================================================ */
:root {
  --sand-900: #1c1209;
  --sand-700: #33220f;
  --gold-500: #e8b23a;
  --gold-700: #a9741c;
  --key-brown: #6e4526;
  --key-brown-hi: #8a5633;
  --cream: #ffefcf;
  --crt: #5cff95;
  --crt-dim: #2e7a4c;
  --crt-bg: #06140c;
  --cyan: #5cd9ff;
  --alert: #ff5d5d;
  --font-ui: "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Yu Gothic UI",
    system-ui, sans-serif;
  --font-term: "JetBrains Mono", "Cascadia Mono", Consolas, "Courier New",
    monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--font-ui);
  color: var(--cream);
  background:
    radial-gradient(ellipse at 50% -20%, #4a3113 0%, transparent 55%),
    repeating-linear-gradient(90deg, transparent 0 120px, rgba(0,0,0,.18) 120px 124px),
    var(--sand-900);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.hidden { display: none !important; }
.screen {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

/* ===== 入場画面 ===== */
.entry-box {
  text-align: center;
  max-width: 560px;
  width: 100%;
  background: linear-gradient(180deg, #3a2712, #241708);
  border: 3px solid var(--gold-700);
  border-radius: 18px;
  box-shadow: 0 0 0 3px #120b04, 0 12px 40px rgba(0,0,0,.6),
    inset 0 2px 0 rgba(255, 220, 140, .25);
  padding: 28px 24px;
}
.game-title {
  font-size: clamp(26px, 5vw, 40px);
  font-weight: 900;
  letter-spacing: .04em;
  color: var(--gold-500);
  text-shadow: 0 2px 0 #5a3c0a, 0 4px 12px rgba(0,0,0,.7);
}
.entry-sub {
  font-family: var(--font-term);
  color: var(--crt);
  font-size: 13px;
  margin: 8px 0 18px;
  letter-spacing: .08em;
  text-shadow: 0 0 8px rgba(92,255,149,.5);
}
.rules {
  text-align: left;
  list-style: none;
  font-size: 14px;
  line-height: 1.9;
  background: rgba(0,0,0,.3);
  border: 1px solid rgba(232,178,58,.35);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 20px;
}
.rules li::before { content: "▸ "; color: var(--gold-500); }
.sym-hit  { color: var(--gold-500); font-weight: 700; }
.sym-blow { color: var(--cyan); font-weight: 700; }
.sym-none { color: #9a8f7d; font-weight: 700; }

.btn-enter {
  font-family: var(--font-ui);
  font-size: 20px;
  font-weight: 800;
  color: #4a3106;
  background: linear-gradient(180deg, #ffd968, var(--gold-500) 55%, #c98f22);
  border: 2px solid #7a5310;
  border-radius: 12px;
  padding: 12px 56px;
  cursor: pointer;
  box-shadow: 0 4px 0 #7a5310, 0 8px 18px rgba(0,0,0,.5);
  transition: transform .08s, box-shadow .08s;
}
.btn-enter:hover { filter: brightness(1.06); }
.btn-enter:active { transform: translateY(3px); box-shadow: 0 1px 0 #7a5310; }
.btn-enter:focus-visible,
.key:focus-visible { outline: 3px solid var(--crt); outline-offset: 2px; }
.entry-player { margin-top: 14px; font-size: 13px; color: #cdb98e; }

/* ===== ゲーム画面 ===== */
#screen-game { justify-content: flex-start; gap: 10px; padding-top: 12px; }

.hud {
  width: min(920px, 100%);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-term);
}
.hud-title {
  color: var(--crt);
  font-size: 15px;
  letter-spacing: .12em;
  text-shadow: 0 0 10px rgba(92,255,149,.55);
}
.hud-title .ver { color: var(--crt-dim); font-size: 12px; }
.hud-try { color: var(--gold-500); font-size: 16px; font-weight: 700; }

.stage {
  width: min(920px, 100%);
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 420px) 1fr;
  gap: 14px;
}

/* --- 金庫側 --- */
.vault {
  background: linear-gradient(180deg, #caa24a 0%, #a97d24 8%, #7c5a17 100%);
  border: 3px solid #5c420f;
  border-radius: 16px;
  box-shadow: inset 0 0 0 4px rgba(255,230,160,.35),
    inset 0 -14px 26px rgba(0,0,0,.35), 0 10px 30px rgba(0,0,0,.55);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

/* シグネチャ: 金庫のスロット窓 */
.slots { display: flex; justify-content: center; gap: 10px; }
.slot {
  width: 64px; height: 76px;
  background: linear-gradient(180deg, #241505, #3a250b 45%, #241505);
  border: 3px solid #5c420f;
  border-radius: 10px;
  box-shadow: inset 0 4px 10px rgba(0,0,0,.8), 0 2px 0 rgba(255,225,150,.35);
  display: grid; place-items: center;
  overflow: hidden;
  perspective: 240px;
}
.slot-num {
  font-family: var(--font-term);
  font-size: 42px;
  font-weight: 700;
  color: var(--crt);
  text-shadow: 0 0 12px rgba(92,255,149,.7);
}
.slot.filled .slot-num { animation: reel-in .18s ease-out; }
.slot.flash-hit   { box-shadow: inset 0 0 18px var(--gold-500), 0 0 14px var(--gold-500); }
.slot.flash-miss  { box-shadow: inset 0 0 18px rgba(255,93,93,.8); }
@keyframes reel-in {
  from { transform: rotateX(80deg) translateY(-16px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* タイマー */
.timerbar-wrap {
  position: relative;
  height: 18px;
  background: #241505;
  border: 2px solid #5c420f;
  border-radius: 9px;
  overflow: hidden;
}
.timerbar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--crt), #b8ff6a);
  transform-origin: left;
}
.timerbar.warn { background: linear-gradient(90deg, #ffb24a, var(--alert)); }
.timer-num {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-family: var(--font-term);
  font-size: 12px; font-weight: 700;
  color: #120b04;
  mix-blend-mode: screen; color: var(--cream);
  text-shadow: 0 1px 2px rgba(0,0,0,.8);
}

/* キーパッド (スクショの茶色ボタンを再現) */
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  flex: 1;
  min-height: 0;
}
.key {
  font-family: var(--font-ui);
  font-size: 26px;
  font-weight: 900;
  color: var(--cream);
  background: linear-gradient(180deg, var(--key-brown-hi), var(--key-brown) 60%, #4e2f18);
  border: 2px solid #3a2210;
  border-radius: 10px;
  box-shadow: 0 4px 0 #3a2210, inset 0 2px 0 rgba(255,220,160,.3);
  cursor: pointer;
  transition: transform .06s, box-shadow .06s, filter .1s;
  text-shadow: 0 2px 2px rgba(0,0,0,.6);
}
.key:hover:not(:disabled) { filter: brightness(1.12); }
.key:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #3a2210; }
.key:disabled { cursor: default; }
.key.selected {
  background: linear-gradient(180deg, #7dffb0, #37c46f 60%, #1f7a43);
  color: #06140c;
  text-shadow: none;
}
.key.banned {
  background: linear-gradient(180deg, #5a1f1f, #401313);
  color: var(--alert);
  text-decoration: line-through;
  box-shadow: 0 4px 0 #2a0c0c;
  opacity: .85;
}
.pad-ctrl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.key-ctrl { font-size: 15px; padding: 10px 0; }
.key-danger { color: #ffc9c9; }

/* --- 解錠デバイス側 --- */
.device {
  background: var(--crt-bg);
  border: 3px solid #14331f;
  border-radius: 14px;
  box-shadow: 0 0 0 3px #0a0f0a, 0 10px 30px rgba(0,0,0,.55),
    inset 0 0 40px rgba(92,255,149,.06);
  display: flex;
  flex-direction: column;
  min-height: 0;
  font-family: var(--font-term);
  position: relative;
}
/* CRT走査線 */
.device::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg, rgba(0,0,0,.22) 0 1px, transparent 1px 3px);
  border-radius: 11px;
}
.device-head {
  padding: 8px 14px;
  color: var(--crt);
  letter-spacing: .18em;
  font-size: 13px;
  border-bottom: 1px solid #14331f;
  text-shadow: 0 0 8px rgba(92,255,149,.5);
}
.log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.75;
  color: var(--crt);
  scrollbar-width: thin;
  scrollbar-color: var(--crt-dim) transparent;
}
.log .empty { color: var(--crt-dim); }
.log .n { color: var(--crt-dim); }
.log .g { color: #d8ffe8; }
.log .hit { color: var(--gold-500); font-weight: 700; }
.log .blow { color: var(--cyan); font-weight: 700; }
.log .none { color: #6b7f70; font-weight: 700; }
.log .to { color: var(--alert); }
.log .hint { color: var(--cyan); }
.log .hint b { color: var(--alert); }
.log .line { animation: log-in .25s ease-out; }
@keyframes log-in { from { opacity: 0; transform: translateX(-6px); } }

.device-foot {
  border-top: 1px solid #14331f;
  padding: 8px 14px;
  font-size: 13px;
  display: flex; gap: 10px; align-items: center;
}
.foot-label { color: var(--crt-dim); letter-spacing: .14em; }
.locked-digits { color: var(--alert); font-weight: 700; letter-spacing: .3em; }

/* --- ネト --- */
.neto {
  width: min(920px, 100%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 6px;
}
.neto-face {
  font-size: 30px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.6));
}
.neto-bubble {
  background: var(--cream);
  color: #3a2a10;
  font-size: 13px;
  font-weight: 700;
  border-radius: 12px;
  padding: 8px 14px;
  position: relative;
  box-shadow: 0 3px 10px rgba(0,0,0,.4);
}
.neto-bubble::before {
  content: "";
  position: absolute; left: -8px; top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: var(--cream);
}

/* ===== 結果オーバーレイ ===== */
.overlay {
  position: fixed; inset: 0;
  background: rgba(10, 6, 2, .82);
  display: grid; place-items: center;
  z-index: 10;
  animation: fade .25s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.overlay-box {
  text-align: center;
  background: linear-gradient(180deg, #3a2712, #241708);
  border: 3px solid var(--gold-700);
  border-radius: 18px;
  padding: 30px 40px;
  max-width: 480px;
  width: calc(100% - 40px);
  box-shadow: 0 16px 50px rgba(0,0,0,.7);
}
#result-title {
  font-family: var(--font-term);
  font-size: 30px;
  letter-spacing: .1em;
  margin-bottom: 10px;
}
#result-title.win { color: var(--gold-500); text-shadow: 0 0 18px rgba(232,178,58,.8); }
#result-title.lose { color: var(--alert); text-shadow: 0 0 14px rgba(255,93,93,.6); }
.result-answer {
  font-family: var(--font-term);
  font-size: 40px;
  letter-spacing: .35em;
  color: var(--crt);
  text-shadow: 0 0 14px rgba(92,255,149,.6);
  margin-bottom: 8px;
}
.result-detail { font-size: 14px; color: #e6d6ae; margin-bottom: 6px; }
.result-neto { font-size: 13px; color: #cdb98e; margin-bottom: 20px; }

/* ===== レスポンシブ ===== */
@media (max-width: 720px) {
  .stage { grid-template-columns: 1fr; grid-template-rows: auto minmax(120px, 1fr); }
  .slot { width: 54px; height: 64px; }
  .slot-num { font-size: 34px; }
  .key { font-size: 22px; padding: 10px 0; }
  .hud-title { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ===== モード選択 / ロビー / ランキング ===== */
.mode-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.mode-btns .btn-enter { padding: 12px 28px; font-size: 18px; }
.btn-multi {
  background: linear-gradient(180deg, #8fffc0, #37c46f 55%, #1f8a4c);
  border-color: #135a31;
  box-shadow: 0 4px 0 #135a31, 0 8px 18px rgba(0,0,0,.5);
  color: #06300f;
}
.btn-multi:active { box-shadow: 0 1px 0 #135a31; }

.lobby-title {
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 900;
  color: var(--gold-500);
  text-shadow: 0 2px 0 #5a3c0a;
}
.lobby-count-wrap {
  position: relative;
  height: 26px;
  background: #241505;
  border: 2px solid #5c420f;
  border-radius: 13px;
  overflow: hidden;
  margin: 14px 0 8px;
}
.lobby-bar {
  height: 100%;
  width: 100%;
  transform-origin: left;
  background: linear-gradient(90deg, var(--crt), #b8ff6a);
}
.lobby-count {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-family: var(--font-term);
  font-size: 13px; font-weight: 700;
  color: var(--cream);
  text-shadow: 0 1px 2px rgba(0,0,0,.8);
}
.lobby-num { font-size: 14px; color: #e6d6ae; margin-bottom: 8px; }
.lobby-num b { color: var(--crt); font-family: var(--font-term); }
.lobby-players {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  max-height: 130px;
  overflow-y: auto;
  margin-bottom: 12px;
}
.lobby-players .chip {
  font-size: 12px;
  font-weight: 700;
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(232,178,58,.4);
  border-radius: 999px;
  padding: 4px 12px;
  animation: log-in .25s ease-out;
}
.lobby-players .chip.you { border-color: var(--crt); color: var(--crt); }
.lobby-note { font-size: 12px; color: #cdb98e; margin-bottom: 14px; }
.lobby-leave { width: auto; padding: 8px 28px; }

.hud-mode {
  color: var(--gold-500);
  font-size: 12px;
  letter-spacing: .2em;
  margin-left: 8px;
}

/* ランキング */
.ranking {
  list-style: none;
  text-align: left;
  max-height: min(300px, 40dvh);
  overflow-y: auto;
  margin: 4px 0 16px;
  font-family: var(--font-term);
  scrollbar-width: thin;
  scrollbar-color: var(--gold-700) transparent;
}
.ranking li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(232,178,58,.18);
  font-size: 14px;
  animation: log-in .25s ease-out;
}
.ranking .rk { width: 42px; color: var(--gold-500); font-weight: 700; }
.ranking li:nth-child(1) .rk { color: #ffe38a; text-shadow: 0 0 8px rgba(232,178,58,.8); }
.ranking .nm {
  flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-ui);
  font-weight: 700;
}
.ranking li.you .nm { color: var(--crt); }
.ranking .sc { color: #e6d6ae; font-size: 13px; }
.ranking li.cleared .sc { color: var(--gold-500); }
.ranking li.uncleared { opacity: .65; }
.overlay-sub { font-size: 12px; color: #cdb98e; margin-top: 10px; }

/* 待機(観戦)表示 */
#result-title.wait {
  color: var(--crt);
  text-shadow: 0 0 14px rgba(92,255,149,.55);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .55; } }

/* ===== v3: 正方形キー / 凡例 / 解錠ストリップ / 演出 ===== */
.keypad {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, clamp(56px, 9dvh, 88px));
  grid-auto-rows: min-content;
  gap: 8px;
  justify-content: center;
  align-content: center;
}
.keypad .key {
  aspect-ratio: 1 / 1;   /* 正方形 */
  width: 100%;
  padding: 0;
}
.pad-ctrl {
  width: min(100%, calc(3 * clamp(56px, 9dvh, 88px) + 16px));
  margin: 0 auto;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
  font-size: 11.5px;
  color: #4a3106;
  font-weight: 700;
  background: rgba(255, 239, 207, .55);
  border-radius: 8px;
  padding: 5px 8px;
}
.legend .sym-none { color: #6b5636; }

/* 解錠ストリップ (マルチ: リアルタイム解錠順) */
.cleared-strip {
  border-top: 1px solid #14331f;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
}
.strip-label {
  color: var(--gold-500);
  font-size: 11px;
  letter-spacing: .14em;
  white-space: nowrap;
  text-shadow: 0 0 8px rgba(232,178,58,.6);
}
.cleared-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.cl-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 44px;
  flex: 0 0 auto;
  animation: unlock-pop .55s cubic-bezier(.2, 1.6, .4, 1);
}
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid var(--gold-500);
  box-shadow: 0 0 10px rgba(232,178,58,.55);
  object-fit: cover;
  background: #241505;
}
.avatar-fallback {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid var(--gold-500);
  display: grid; place-items: center;
  background: #3a2712;
  color: var(--gold-500);
  font-weight: 900;
  font-size: 14px;
  font-family: var(--font-ui);
}
.cl-rank {
  position: absolute;
  top: -6px; left: -2px;
  background: var(--gold-500);
  color: #4a3106;
  font-family: var(--font-term);
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 0 5px;
  box-shadow: 0 1px 3px rgba(0,0,0,.6);
}
.cl-name {
  max-width: 44px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 9.5px;
  color: #d8ffe8;
  margin-top: 2px;
}
@keyframes unlock-pop {
  0%   { transform: scale(0) rotate(-25deg); filter: brightness(3); }
  60%  { transform: scale(1.18) rotate(4deg); }
  100% { transform: none; filter: none; }
}

/* 画面フラッシュ演出 */
#fx-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  opacity: 0;
  background: radial-gradient(circle at 50% 45%,
    rgba(255,225,140,.9), rgba(232,178,58,.35) 40%, transparent 70%);
}
#fx-flash.go { animation: gold-flash .55s ease-out; }
#fx-flash.strong { animation: gold-flash-strong .8s ease-out; }
@keyframes gold-flash { 0% { opacity: .75; } 100% { opacity: 0; } }
@keyframes gold-flash-strong {
  0% { opacity: 1; transform: scale(1.05); }
  100% { opacity: 0; transform: none; }
}

/* ランキングの登場演出 */
.overlay-box.boom { animation: box-boom .5s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes box-boom {
  0% { transform: scale(.6); opacity: 0; filter: brightness(2.2); }
  100% { transform: none; opacity: 1; filter: none; }
}
.ranking li { opacity: 0; animation: rank-in .4s ease-out forwards; }
@keyframes rank-in {
  from { opacity: 0; transform: translateX(-18px); }
  to   { opacity: 1; transform: none; }
}
.ranking .avatar, .ranking .avatar-fallback {
  width: 24px; height: 24px;
  align-self: center;
  font-size: 12px;
}
.ranking li.uncleared .avatar,
.ranking li.uncleared .avatar-fallback {
  border-color: #6b5636;
  box-shadow: none;
  filter: grayscale(.6);
}

/* ミュートボタン */
.mute-btn {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 30;
  width: 40px;
  height: 40px;
  font-size: 18px;
  background: rgba(36, 21, 5, .8);
  border: 2px solid var(--gold-700);
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: filter .1s;
}
.mute-btn:hover { filter: brightness(1.3); }
.mute-btn:focus-visible { outline: 3px solid var(--crt); outline-offset: 2px; }

/* 画面内デバッグ表示 */
.diag {
  position: fixed;
  left: 8px; right: 8px; bottom: 8px;
  z-index: 99;
  background: rgba(64, 12, 12, .95);
  border: 1px solid var(--alert);
  border-radius: 8px;
  color: #ffd4d4;
  font-family: var(--font-term);
  font-size: 12px;
  line-height: 1.6;
  padding: 8px 12px;
  word-break: break-all;
}
