/* ==========================================================
   危険なエレベーター脱出 -Elevator Panic- - style.css
   ========================================================== */

:root {
  --color-bg-top: #1a1418;
  --color-bg-bottom: #0a0709;
  --color-box: #201a1e;
  --color-box-border: #ff5c5c;
  --color-primary: #ff5c5c;
  --color-primary-2: #ffb347;
  --color-good: #4fe38a;
  --color-danger: #ff4d4d;
  --color-text: #f5eef0;
  --color-text-muted: #b39aa0;
  --color-border: #4a353c;
  --header-h: 56px;
  --ad-h: 60px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Segoe UI", Roboto, Arial, sans-serif;
  background: linear-gradient(180deg, var(--color-bg-top), var(--color-bg-bottom));
  color: var(--color-text);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

img, canvas { image-rendering: pixelated; image-rendering: crisp-edges; }

/* ---------- ヘッダー ---------- */
.game-header {
  height: var(--header-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.8rem;
  background: rgba(10, 7, 9, 0.85);
  border-bottom: 2px solid var(--color-box-border);
  position: relative;
  z-index: 45;
}

.back-link {
  color: var(--color-text);
  text-decoration: none;
  font-size: 1.3rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  flex: 0 0 auto;
}

.back-link:active { background: rgba(255, 255, 255, 0.2); }

.game-title {
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  margin: 0;
  color: var(--color-primary-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions { display: flex; align-items: center; gap: 0.35rem; flex: 0 0 auto; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-text);
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:active { background: rgba(255, 255, 255, 0.22); }
.icon-btn.is-muted { color: var(--color-text-muted); }

/* ---------- HUD ---------- */
.stat-row {
  flex: 0 0 auto;
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem 0.6rem 0.3rem;
  z-index: 10;
}

.stat-box {
  flex: 1 1 0;
  min-width: 0;
  background: rgba(32, 26, 30, 0.8);
  border: 2px solid var(--color-border);
  border-radius: 12px;
  padding: 0.3rem 0.5rem;
  text-align: center;
  line-height: 1.25;
}

.stat-box__label {
  display: block;
  font-size: 0.6rem;
  font-weight: bold;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.stat-box__value {
  display: block;
  font-size: 0.95rem;
  font-weight: 900;
  color: var(--color-primary-2);
  white-space: nowrap;
}

/* ---------- シャフトステージ ---------- */
.shaft-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: stretch;
  gap: 0.4rem;
  padding: 0 0.5rem;
  overflow: hidden;
}

.gauge {
  flex: 0 0 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0;
  z-index: 12;
}

.gauge__label {
  font-size: 0.58rem;
  font-weight: 900;
  color: var(--color-text-muted);
  letter-spacing: 0.05em;
}

.gauge__bar {
  flex: 1 1 auto;
  width: 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid var(--color-border);
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}

.gauge__bar-fill {
  width: 100%;
  height: 0%;
  background: linear-gradient(0deg, var(--color-good), var(--color-primary-2) 60%, var(--color-danger));
  transition: height 0.08s linear;
}

.gauge__floor-value {
  font-size: 1rem;
  font-weight: 900;
  color: var(--color-primary-2);
  writing-mode: horizontal-tb;
  font-variant-numeric: tabular-nums;
}

.shaft-viewport {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--color-border);
  touch-action: none;
}

#shaft-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.telop-layer {
  position: absolute;
  top: 8%;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 8;
  pointer-events: none;
}

.telop {
  font-size: 0.9rem;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, rgba(255, 92, 92, 0.92), rgba(255, 179, 71, 0.92));
  padding: 0.4rem 1rem;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
  transform: scale(0.5);
  opacity: 0;
  animation: telop-pop 1.5s ease forwards;
}

@keyframes telop-pop {
  0% { transform: scale(0.4); opacity: 0; }
  15% { transform: scale(1.12); opacity: 1; }
  25% { transform: scale(1); opacity: 1; }
  75% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.92); opacity: 0; }
}

/* ---------- 操作ヒント ---------- */
.control-hint {
  position: absolute;
  bottom: calc(var(--ad-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9;
  font-size: 0.74rem;
  font-weight: bold;
  color: #fff;
  background: rgba(10, 7, 9, 0.75);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.control-hint.is-visible { opacity: 1; }

/* ---------- オーバーレイ ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 4, 5, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 1rem;
}

.overlay.is-visible { opacity: 1; pointer-events: auto; }

.overlay__box {
  text-align: center;
  padding: 1.8rem 2rem;
  background: var(--color-box);
  border: 3px solid var(--color-box-border);
  border-radius: 22px;
  max-width: 85%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.overlay__box--wide {
  max-width: min(92%, 460px);
  max-height: 88%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.guide-section { text-align: left; margin: 1rem 0; }
.guide-section__title { font-size: 0.92rem; color: var(--color-primary-2); margin: 0 0 0.4rem; }
.guide-section__text { font-size: 0.82rem; color: var(--color-text-muted); margin: 0; line-height: 1.6; }
.guide-section__list { margin: 0; padding-left: 1.1rem; font-size: 0.8rem; color: var(--color-text-muted); line-height: 1.7; }
.guide-section__list li { margin-bottom: 0.3rem; }

.overlay__title { font-size: 1.3rem; font-weight: 900; margin: 0 0 0.5rem; color: var(--color-primary-2); }
.overlay__result-emoji { font-size: 2.4rem; margin: 0 0 0.2rem; }
.overlay__desc { color: var(--color-text-muted); margin: 0 0 1.3rem; font-size: 0.88rem; font-weight: bold; white-space: pre-line; line-height: 1.6; }

.overlay__btn {
  border: none;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-2));
  color: #200a0a;
  font-weight: 900;
  font-size: 0.95rem;
  padding: 0.8rem 1.8rem;
  border-radius: 999px;
  cursor: pointer;
}

.overlay__btn:active { filter: brightness(0.92); }

/* ---------- 広告スペース ---------- */
.ad-gap { flex: 0 0 6px; }

.ad-slot {
  flex: 0 0 var(--ad-h);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 0.7rem 0.6rem;
  border: 2px dashed var(--color-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--color-text-muted);
  font-size: 0.72rem;
  z-index: 20;
  overflow: hidden;
}

@media (max-height: 640px) {
  .ad-slot { --ad-h: 44px; font-size: 0.65rem; }
  .gauge { flex-basis: 36px; }
}
