/* BACKEND DAYS - css/style.css
   共通HUD・UI・画面遷移のスタイル。UIはHTML/CSS(§16)。 */

:root {
  --bg: #0a0e14;
  --bg-panel: #0f1520;
  --line: #2a3850;
  --text: #cfe3ff;
  --text-dim: #8fa3bd;
  --accent: #00e5ff;
  --accent-dim: #0891b2;
  --warn: #ff9800;
  --danger: #e53935;
  --ok: #4caf50;
  --mono: "Courier New", Consolas, "Yu Gothic UI", Meiryo, monospace;
  --ui: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  --surface: rgba(15, 21, 32, 0.91);
  --focus: #fff3a3;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  overflow: hidden;
}

.hidden { display: none !important; }

#app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }

#game-area { position: relative; flex: 1; overflow: hidden; }

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
}

/* ---------- 共通HUD ---------- */

#hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  background: linear-gradient(180deg, rgba(10, 14, 20, 0.95), rgba(10, 14, 20, 0.75));
  border-bottom: 1px solid var(--line);
  z-index: 10;
  pointer-events: none;
}

.hud-title {
  font-weight: bold;
  letter-spacing: 3px;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.5);
}

.hud-day { color: var(--text-dim); letter-spacing: 2px; }

#hud-bottom {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: linear-gradient(0deg, rgba(10, 14, 20, 0.95), rgba(10, 14, 20, 0.75));
  border-top: 1px solid var(--line);
  z-index: 10;
}

.hud-objective { flex: 1; min-width: 0; }
.hud-objective .label {
  color: var(--accent-dim);
  font-size: 11px;
  letter-spacing: 2px;
  margin-right: 10px;
}
#hud-objective-text { color: var(--text); font-size: 14px; }

.hud-tabs { display: flex; gap: 6px; }

.hud-tabs button {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 1px;
  padding: 6px 14px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s, transform 0.15s;
}
.hud-tabs button:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.hud-tabs button.active {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.3) inset;
}

/* ---------- パネル ---------- */

.hud-panel {
  position: absolute;
  bottom: 58px;
  width: 360px;
  max-height: min(300px, calc(100dvh - 136px));
  background: var(--surface);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  z-index: 20;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.7;
  overflow: auto;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
}
#panel-tools { left: 18px; }
#panel-debug { right: 18px; }
#panel-log { left: 50%; transform: translateX(-50%); width: 460px; }

.panel-title {
  color: var(--accent-dim);
  font-size: 11px;
  letter-spacing: 2px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  margin-bottom: 6px;
}

#debug-content {
  font-family: var(--mono);
  color: #7ee787;
  white-space: pre-wrap;
}

#log-content { color: var(--text-dim); }
.log-line { border-left: 2px solid var(--line); padding-left: 8px; margin-bottom: 2px; }
.log-line:last-child { color: var(--text); border-left-color: var(--accent); }

.tool-hint { color: var(--text-dim); }
.tool-hint br + * { margin-top: 4px; }

/* ---------- 全画面オーバーレイ ---------- */

#scene-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  overflow: auto;
  isolation: isolate;
}

.screen {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(32px, env(safe-area-inset-top)) max(32px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(32px, env(safe-area-inset-left));
  animation: fadein 0.5s ease;
  position: relative;
}

/* 背景画像を覆い隠さず、全画面に薄い粒子感と奥行きを加える共通レイヤー。 */
.screen::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.34;
  background-image: radial-gradient(circle at 20% 10%, rgba(0, 229, 255, 0.20), transparent 28%),
    linear-gradient(115deg, rgba(255,255,255,0.025) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.025) 50%, rgba(255,255,255,0.025) 75%, transparent 75%);
  background-size: auto, 5px 5px;
}

.screen > * { position: relative; z-index: 1; }

@keyframes fadein {
  from { opacity: 0; }
  to { opacity: 1; }
}

button {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 2px;
  padding: 10px 26px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, box-shadow 0.15s, background 0.15s, transform 0.15s;
}
button:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
button:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.4);
}
button:disabled { opacity: 0.35; cursor: not-allowed; }
button:disabled:hover { border-color: var(--line); color: var(--text); }

.btn-primary {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.25);
}
.btn-primary:hover { box-shadow: 0 0 24px rgba(0, 229, 255, 0.45); }
.btn-danger { border-color: var(--danger); color: var(--danger); }

/* ---------- タイトル ---------- */

.title-screen { text-align: center; }

.title-system {
  color: var(--warn);
  font-size: 12px;
  letter-spacing: 3px;
  margin-bottom: 18px;
  animation: blink 2s infinite;
}
@keyframes blink { 50% { opacity: 0.4; } }

.title-logo {
  font-size: clamp(40px, 8vw, 88px);
  letter-spacing: 8px;
  color: #fff;
  text-shadow: 0 0 30px rgba(0, 229, 255, 0.6);
}
.title-logo .title-days {
  color: var(--accent);
  margin-left: 18px;
}

/* タイトルロゴ画像(assets/ui/title_BACKEND_DAYS.png) */
.title-logo-img {
  width: min(560px, 80vw);
  max-height: 240px;
  object-fit: contain;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.65)) drop-shadow(0 0 20px rgba(0, 229, 255, 0.35));
  margin: 12px 0;
  animation: title-settle 0.8s cubic-bezier(.2,.8,.2,1) both;
}

@keyframes title-settle {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.title-sub { color: var(--text-dim); margin: 8px 0 36px; letter-spacing: 2px; }

.title-menu { display: flex; flex-direction: column; gap: 12px; width: 260px; }
.title-menu button { min-height: 44px; }

.title-footer {
  margin-top: 40px;
  color: #4a5a70;
  font-size: 11px;
  line-height: 1.9;
}

/* ---------- SYSTEM MESSAGE ---------- */

.sysmsg-screen { justify-content: center; }

.sysmsg {
  font-family: var(--mono);
  font-size: clamp(16px, 2.4vw, 24px);
  line-height: 2;
  color: #7ee787;
  text-shadow: 0 0 10px rgba(126, 231, 135, 0.4);
  white-space: pre-wrap;
  min-height: 50vh;
  min-width: min(640px, 90vw);
}

.sysmsg::after {
  content: "▌";
  animation: blink 0.8s infinite;
  color: #7ee787;
}

.sysmsg-actions { margin-top: 30px; min-height: 50px; }

.sysmsg-hint { margin-top: 14px; color: #4a5a70; font-size: 11px; }

/* ---------- DAY SELECT ---------- */

.dayselect-screen { justify-content: flex-start; padding-top: 24px; }

.dayselect-head {
  width: min(1100px, 95vw);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.dayselect-title { color: var(--accent); letter-spacing: 2px; font-weight: bold; }

.dayselect-body { width: min(1100px, 95vw); }

.act-section { margin-bottom: 22px; }

.act-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  margin-bottom: 12px;
}
.act-name { color: var(--accent); font-weight: bold; letter-spacing: 2px; }
.act-sub { color: #4a5a70; font-size: 12px; }

.act-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.day-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
  padding: 12px 14px;
  font-size: 12px;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, rgba(20, 31, 47, 0.96), rgba(11, 17, 28, 0.96));
  min-height: 108px;
}
.day-card .day-num { color: var(--accent); font-weight: bold; }
.day-card .day-title { color: #fff; font-size: 14px; }
.day-card .day-chips { color: #4a5a70; font-size: 11px; }
.day-card .day-state { align-self: flex-end; color: var(--text-dim); font-size: 11px; }
.day-card.cleared .day-state { color: var(--ok); }
.day-card.locked { opacity: 0.45; }
.day-card:not(.locked):hover { border-color: var(--accent); }
.day-card.cleared { border-left: 3px solid var(--ok); }

/* ---------- DISCOVERY / RESULT ---------- */

.discovery-screen, .result-screen { text-align: center; }

.disc-head {
  color: var(--accent);
  font-size: clamp(28px, 5vw, 44px);
  letter-spacing: 10px;
  text-shadow: 0 0 24px rgba(0, 229, 255, 0.6);
}

.disc-sub { color: var(--text-dim); margin: 12px 0 6px; letter-spacing: 1px; }

.disc-summary { color: #7ee787; font-size: 13px; margin-bottom: 10px; }

.disc-list {
  margin: 26px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(720px, 92vw);
}

.disc-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(100deg, rgba(20, 33, 48, 0.94), rgba(12, 19, 30, 0.94));
  border: 1px solid var(--line);
  padding: 10px 16px;
  text-align: left;
  animation: fadein 0.6s both;
}
.disc-row:nth-child(1) { animation-delay: 0.1s; }
.disc-row:nth-child(2) { animation-delay: 0.25s; }
.disc-row:nth-child(3) { animation-delay: 0.4s; }
.disc-row:nth-child(4) { animation-delay: 0.55s; }
.disc-row:nth-child(5) { animation-delay: 0.7s; }
.disc-row:nth-child(6) { animation-delay: 0.85s; }

.disc-name { color: var(--accent); font-weight: bold; min-width: 110px; letter-spacing: 1px; }
.disc-game { color: var(--text); }
.disc-arrow { color: #4a5a70; }
.disc-real { color: var(--text-dim); }

.disc-actions { display: flex; gap: 12px; margin-top: 18px; flex-wrap: wrap; justify-content: center; }

.disc-final { margin-top: 22px; color: var(--warn); font-size: 13px; letter-spacing: 1px; }

.result-title {
  font-size: clamp(32px, 6vw, 56px);
  letter-spacing: 8px;
}
.result-title.fail { color: var(--danger); text-shadow: 0 0 24px rgba(229, 57, 53, 0.5); }
.result-sub { color: var(--text-dim); margin-top: 12px; }
.result-hint { color: var(--warn); margin: 18px 0 8px; font-size: 13px; }

/* ---------- RPG型ダイアログ(§38) ---------- */

#dialogue {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 16px;
  width: min(920px, 94%);
  min-height: 150px;
  display: flex;
  gap: 14px;
  background: rgba(10, 17, 29, 0.94);
  backdrop-filter: blur(12px);
  border: 2px solid var(--accent-dim);
  border-radius: 10px;
  padding: 14px 18px;
  z-index: 60;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.7), 0 0 20px rgba(0, 229, 255, 0.12);
  cursor: pointer;
}

.dialogue-faces { display: flex; gap: 10px; align-items: flex-end; flex: 0 0 auto; }

.dialogue-face-frame { position: relative; }

.dialogue-face-frame canvas {
  width: 110px;
  height: 110px;
  background: #0a0e14;
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: opacity 0.2s;
}

/* 話者がすぐる以外のとき、左のすぐるは控えめに表示 */
.dialogue-face-frame canvas.dim { opacity: 0.45; }

.dialogue-face-label {
  position: absolute;
  left: 1px;
  right: 1px;
  bottom: 1px;
  text-align: center;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text-dim);
  background: rgba(10, 14, 20, 0.78);
  border-radius: 0 0 7px 7px;
  pointer-events: none;
}

#dialogue-main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }

#dialogue-name {
  align-self: flex-start;
  background: var(--accent-dim);
  color: #04121a;
  font-weight: bold;
  font-size: 13px;
  letter-spacing: 2px;
  padding: 2px 12px;
  border-radius: 4px;
  margin-bottom: 8px;
}

#dialogue-text {
  color: var(--text);
  font-size: 15px;
  line-height: 1.8;
  white-space: pre-wrap;
  min-height: 76px;
}

#dialogue-next {
  position: absolute;
  right: 0;
  bottom: 0;
  color: var(--accent);
  animation: blink 0.9s infinite;
  font-size: 14px;
}

#dialogue-choices {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.dlg-choice {
  text-align: left;
  font-size: 13px;
  padding: 8px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  color: var(--text);
}
.dlg-choice:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 小画面 / タッチ操作 ---------- */

@media (max-width: 720px) {
  #hud-top { padding: 8px 12px; }
  .hud-title { font-size: 12px; letter-spacing: 2px; }
  .hud-day { font-size: 12px; letter-spacing: 1px; }
  #hud-bottom { align-items: stretch; flex-direction: column; gap: 7px; padding: 8px 12px; }
  .hud-objective { display: flex; gap: 7px; align-items: baseline; }
  .hud-objective .label { flex: none; margin: 0; }
  #hud-objective-text { font-size: 12px; line-height: 1.45; }
  .hud-tabs { width: 100%; }
  .hud-tabs button { flex: 1; min-height: 34px; padding: 6px 8px; }
  .hud-panel { bottom: 112px; left: 12px !important; right: 12px !important; width: auto !important; transform: none !important; max-height: min(46dvh, 330px); }
  .screen { padding: 22px 16px; }
  .title-logo-img { width: min(520px, 92vw); }
  .title-sub { margin: 12px 0 28px; font-size: 13px; }
  .title-footer { margin-top: 26px; font-size: 10px; }
  .dayselect-screen { padding-top: 18px; }
  .dayselect-head { width: 100%; gap: 12px; margin-bottom: 14px; }
  .dayselect-title { font-size: 13px; line-height: 1.5; }
  .dayselect-body { width: 100%; }
  .act-grid { grid-template-columns: 1fr; gap: 8px; }
  .day-card { min-height: 86px; }
  .disc-list { margin: 18px 0; gap: 7px; }
  .disc-row { align-items: flex-start; flex-wrap: wrap; gap: 5px 9px; padding: 10px 12px; font-size: 13px; }
  .disc-name { min-width: auto; width: 100%; }
  #dialogue { bottom: 8px; width: calc(100% - 16px); gap: 8px; min-height: 126px; padding: 9px 10px; border-radius: 8px; }
  .dialogue-faces { gap: 5px; }
  .dialogue-face-frame canvas { width: 72px; height: 72px; }
  .dialogue-face-label { font-size: 9px; letter-spacing: 0; }
  #dialogue-name { font-size: 11px; padding: 2px 8px; margin-bottom: 4px; }
  #dialogue-text { font-size: 13px; line-height: 1.65; min-height: 68px; padding-right: 10px; }
  .dlg-choice { font-size: 12px; padding: 7px 9px; }
}

@media (max-width: 390px) {
  .dialogue-face-frame canvas { width: 58px; height: 58px; }
  #dialogue-text { font-size: 12px; }
  .title-menu { width: min(260px, 100%); }
  .sysmsg { min-width: 0; font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}

/* ---------- EXTRA (CLEAR BONUS) ---------- */
.title-extra-menu {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: fadeIn 0.8s ease-out;
}

.title-extra-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  color: #ffd54f;
  background: rgba(255, 213, 79, 0.12);
  border: 1px solid rgba(255, 213, 79, 0.35);
  padding: 4px 14px;
  border-radius: 20px;
  text-shadow: 0 0 10px rgba(255, 213, 79, 0.5);
  box-shadow: 0 0 16px rgba(255, 213, 79, 0.15);
}

.title-extra-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-extra {
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.18), rgba(255, 100, 200, 0.18));
  border: 1.5px solid #00e5ff;
  color: #ffffff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(0, 229, 255, 0.2);
}

.btn-extra:hover {
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.35), rgba(255, 100, 200, 0.35));
  border-color: #ffd54f;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 213, 79, 0.35);
}

.title-extra-locked {
  margin-top: 14px;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: #5d7088;
  padding: 4px 12px;
  border: 1px dashed rgba(93, 112, 136, 0.4);
  border-radius: 4px;
  background: rgba(10, 16, 24, 0.4);
}
