:root {
  --bg-dark: #070608;
  --panel-bg: rgba(14, 12, 16, 0.86);
  --panel-border: rgba(135, 110, 75, 0.42);
  --text-main: #e8e1d5;
  --text-muted: #9b9286;
  --blood: #b81d24;
  --blood-bright: #ef333c;
  --brass: #d4aa64;
  --safe: #4da66d;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
}

#game-wrapper {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

#qteCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 15;
}

#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-left: -3px;
  margin-top: -3px;
  border-radius: 50%;
  background: rgba(248, 235, 210, 0.72);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  z-index: 12;
}

#hide-slit {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  background:
    linear-gradient(90deg, rgba(4, 3, 5, 0.96) 0%, rgba(4, 3, 5, 0.96) 33%, transparent 39%, transparent 45%, rgba(4, 3, 5, 0.95) 49%, rgba(4, 3, 5, 0.95) 51%, transparent 55%, transparent 61%, rgba(4, 3, 5, 0.96) 67%, rgba(4, 3, 5, 0.96) 100%),
    linear-gradient(180deg, rgba(4, 3, 5, 0.95) 0%, transparent 18%, transparent 82%, rgba(4, 3, 5, 0.95) 100%);
}

#pointer-lock-hint {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: 4px;
  background: rgba(14, 12, 16, 0.88);
  border: 1px solid rgba(212, 170, 100, 0.5);
  color: #f3dfb6;
  font-size: 12px;
  pointer-events: none;
  z-index: 16;
}

.hidden {
  display: none !important;
}

/* 雰囲気用ビネット・エフェクト */
#danger-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 42%, rgba(165, 10, 18, 0.65) 100%);
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 5;
}

#frenzy-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 55%, rgba(190, 15, 20, 0.4) 100%);
  animation: frenzyPulse 1.1s infinite alternate ease-in-out;
  z-index: 4;
}

@keyframes frenzyPulse {
  from { opacity: 0.35; }
  to { opacity: 0.85; }
}

#jumpscare-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255, 35, 35, 0.92) 0%, rgba(40, 0, 0, 0.98) 70%);
  z-index: 50;
  animation: scareFlash 0.45s ease-out forwards;
}

@keyframes scareFlash {
  0% { opacity: 1; transform: scale(1.05); }
  50% { opacity: 0.85; transform: scale(1); }
  100% { opacity: 0; }
}

/* HUD 共通 */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.7), inset 0 0 14px rgba(0, 0, 0, 0.6);
  border-radius: 6px;
  backdrop-filter: blur(4px);
}

/* 左上: レシピ一覧 */
#hud-recipes {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 295px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding: 10px 12px;
  pointer-events: auto;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--brass);
  border-bottom: 1px solid rgba(212, 170, 100, 0.22);
  padding-bottom: 6px;
  margin-bottom: 8px;
}

.blood-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blood-bright);
  box-shadow: 0 0 8px var(--blood-bright);
}

#recipe-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.recipe-item {
  font-size: 12px;
  padding: 5px 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid #4d453b;
}

.recipe-item.done {
  border-left-color: var(--safe);
  opacity: 0.62;
  text-decoration: line-through;
}

.recipe-item.ready {
  border-left-color: var(--brass);
  background: rgba(212, 170, 100, 0.1);
}

.recipe-name {
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  margin-bottom: 3px;
}

.recipe-reqs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.req-chip {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
}

.req-chip.delivered {
  color: #9be2b1;
  border-color: rgba(77, 166, 109, 0.6);
  background: rgba(77, 166, 109, 0.14);
}

.req-chip.carried {
  color: #f6d58c;
  border-color: rgba(212, 170, 100, 0.7);
}

.step-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 3px;
}

.step-row {
  font-size: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  line-height: 1.25;
}

.step-done {
  color: #82cf9a;
  text-decoration: line-through;
  opacity: 0.7;
}

.step-active {
  color: #f8e5bd;
  font-weight: 700;
}

.step-pending {
  color: #8a8278;
}

.step-chips {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}

.st-tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 0 4px;
  border-radius: 3px;
  color: #120f12;
}
.st-tag-prep { background: #f0c050; }
.st-tag-stove { background: #ff7a45; }
.st-tag-counter { background: #7cd4ff; }

#escape-banner {
  margin-top: 8px;
  padding: 6px 8px;
  background: rgba(184, 29, 36, 0.35);
  border: 1px solid var(--blood-bright);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  color: #ffd5d5;
  text-align: center;
  animation: frenzyPulse 0.8s infinite alternate;
}

/* 右上: ミニマップ & ミュート */
#hud-top-right {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

#minimap-box {
  padding: 6px;
  pointer-events: auto;
  cursor: pointer;
}

.minimap-label {
  font-size: 11px;
  color: var(--brass);
  margin-bottom: 4px;
  text-align: center;
  letter-spacing: 0.05em;
}

#minimapCanvas {
  display: block;
  border-radius: 3px;
  border: 1px solid rgba(212, 170, 100, 0.25);
  background: #14110e;
}

.icon-btn {
  pointer-events: auto;
  width: 38px;
  height: 38px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  color: var(--text-main);
  font-size: 17px;
  cursor: pointer;
}

.icon-btn:hover {
  border-color: var(--brass);
}

/* 左下: ステータス */
#hud-status {
  position: absolute;
  left: 14px;
  bottom: 14px;
  width: 245px;
  padding: 10px 12px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.status-label {
  font-size: 11px;
  color: var(--text-muted);
  width: 52px;
}

.bar-track {
  flex: 1;
  height: 9px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.bar-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #b88b3d, #ebd08d);
  transition: width 0.08s linear;
}

.bar-fill.exhausted {
  background: linear-gradient(90deg, #8b1e24, #d6454d);
}

.status-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.badge-on {
  color: #ffe9a8;
  border-color: rgba(235, 208, 141, 0.55);
  background: rgba(212, 170, 100, 0.14);
}

.badge-off {
  color: #8f8a82;
}

.badge-danger {
  color: #fff;
  background: rgba(184, 29, 36, 0.75);
  border-color: var(--blood-bright);
  animation: frenzyPulse 0.45s infinite alternate;
}

/* 中央下部: インタラクト & 調理ゲージ */
#interact-area {
  position: absolute;
  left: 50%;
  bottom: 112px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

#interact-prompt {
  padding: 7px 14px;
  border-radius: 5px;
  background: rgba(10, 9, 12, 0.88);
  border: 1px solid var(--brass);
  font-size: 13px;
  font-weight: 600;
  color: #f8ebd2;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.75);
}

#cooking-progress-box {
  width: 300px;
  padding: 10px 14px;
  border-radius: 6px;
  background: rgba(14, 10, 10, 0.92);
  border: 1px solid var(--brass);
  text-align: center;
}

#cooking-title {
  font-size: 13px;
  font-weight: 700;
  color: #f5d896;
  margin-bottom: 6px;
}

.cook-track {
  height: 12px;
  background: rgba(255, 255, 255, 0.09);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.cook-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #c95f1e, #f2b749);
}

.cook-hint {
  margin-top: 5px;
  font-size: 11px;
  color: var(--text-muted);
}

/* 下部中央: インベントリ */
#hud-inventory {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.inv-group-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-align: center;
}

.slot-row {
  display: flex;
  gap: 8px;
}

.inv-slot {
  width: 68px;
  height: 54px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(212, 170, 100, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  text-align: center;
  padding: 3px;
}

.inv-slot.empty {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.14);
}

.inv-slot.selected {
  box-shadow: 0 0 0 2px #fff2cc, 0 0 12px rgba(240, 192, 80, 0.55);
  transform: translateY(-3px);
}

.inv-slot .slot-icon {
  font-size: 20px;
  line-height: 1.1;
}

.inv-slot .slot-name {
  font-size: 9px;
  color: var(--text-main);
  margin-top: 2px;
  line-height: 1.1;
}

.inv-slot .slot-cat {
  font-size: 8px;
  font-weight: 700;
  padding: 0 4px;
  border-radius: 3px;
  margin-bottom: 1px;
  letter-spacing: 0.04em;
}

.inv-slot.cat-tool {
  border-color: rgba(240, 192, 80, 0.85);
  background: rgba(240, 192, 80, 0.1);
}
.inv-slot.cat-tool .slot-cat {
  color: #1a1406;
  background: #f0c050;
}

.inv-slot.cat-ingredient {
  border-color: rgba(88, 214, 141, 0.85);
  background: rgba(88, 214, 141, 0.1);
}
.inv-slot.cat-ingredient .slot-cat {
  color: #061c10;
  background: #58d68d;
}

.inv-slot.cat-decoy {
  border-color: rgba(93, 173, 226, 0.85);
  background: rgba(93, 173, 226, 0.1);
}
.inv-slot.cat-decoy .slot-cat {
  color: #061522;
  background: #5dade2;
}

.inv-divider {
  width: 1px;
  height: 52px;
  background: rgba(212, 170, 100, 0.25);
}

/* トースト通知 */
#toast-container {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.toast {
  padding: 7px 14px;
  border-radius: 4px;
  background: rgba(14, 12, 14, 0.92);
  border: 1px solid var(--brass);
  color: #f4e6ca;
  font-size: 13px;
  font-weight: 600;
  animation: toastFade 2.6s ease forwards;
}

.toast.danger {
  border-color: var(--blood-bright);
  color: #ffc5c5;
}

@keyframes toastFade {
  0% { opacity: 0; transform: translateY(-6px); }
  12% { opacity: 1; transform: translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-6px); }
}

/* モーダル（拡大見取り図） */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}

.map-card {
  background: #191410;
  border: 2px solid var(--brass);
  border-radius: 8px;
  padding: 16px 20px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.9);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--brass);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title .sub {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

#fullmapCanvas {
  display: block;
  border-radius: 4px;
  border: 1px solid rgba(212, 170, 100, 0.35);
  background: #14100c;
}

.map-legend {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12px;
  color: var(--text-main);
  align-items: center;
}

.leg-box {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 5px;
  vertical-align: -1px;
  border-radius: 2px;
}

.leg-you { background: #5be8ff; }
.leg-kitchen { background: #e8a748; }
.leg-exit { background: #4cd97b; }
.leg-item { background: #f7e26b; }
.leg-tool { background: #f0c050; }
.leg-ing { background: #58d68d; }
.leg-hide { background: #9b88c9; }
.leg-warn { color: #e56f6f; margin-left: auto; }

/* オーバーレイ画面 (タイトル / ゲームオーバー / クリア) */
.overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, rgba(28, 12, 14, 0.86) 0%, rgba(5, 4, 6, 0.97) 75%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 20px;
}

.title-overlay {
  background: radial-gradient(circle at center, rgba(16, 10, 12, 0.42) 0%, rgba(4, 3, 5, 0.82) 78%);
}

.top-right-btns {
  display: flex;
  gap: 8px;
}

.debug-badge {
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(88, 214, 141, 0.22);
  border: 1px solid #58d68d;
  color: #a9f0c5;
  font-size: 11px;
  font-weight: 700;
}

.title-menu-card {
  max-width: 520px;
  background: rgba(12, 10, 13, 0.82);
  backdrop-filter: blur(6px);
}

.menu-stack {
  display: flex;
  flex-direction: column;
  gap: 11px;
  max-width: 280px;
  margin: 8px auto 0;
}

.menu-btn {
  width: 100%;
}

.secondary-btn {
  padding: 11px 24px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-main);
  background: rgba(34, 29, 28, 0.92);
  border: 1px solid rgba(212, 170, 100, 0.45);
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.secondary-btn:hover {
  transform: translateY(-1px);
  border-color: var(--brass);
}

.debug-note {
  margin-top: 14px;
  font-size: 12px;
  color: #7ee3a6;
}

.controls-card {
  max-width: 680px;
  width: 92%;
  text-align: center;
}

.settings-card {
  max-width: 460px;
  width: 92%;
}

.setting-row {
  margin: 14px 0;
}

.setting-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.setting-label {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 6px;
}

.setting-val {
  color: var(--brass);
  font-weight: 700;
}

.setting-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.setting-divider {
  height: 1px;
  background: rgba(212, 170, 100, 0.22);
  margin: 16px 0;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--brass);
  cursor: pointer;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #312c29;
  border: 1px solid #6b5e4c;
  border-radius: 24px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: #e8e1d5;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: #2f7d52;
  border-color: #58d68d;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

.settings-actions {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.end-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.title-card, .end-card {
  max-width: 680px;
  width: 100%;
  background: rgba(16, 13, 15, 0.95);
  border: 1px solid rgba(212, 170, 100, 0.45);
  border-radius: 10px;
  padding: 30px 34px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.92);
}

.eyebrow, .end-tag {
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--blood-bright);
  margin-bottom: 8px;
}

.clear-tag {
  color: var(--safe);
}

h1 {
  font-size: 40px;
  letter-spacing: 0.08em;
  color: #f3e4cb;
  text-shadow: 0 0 24px rgba(184, 29, 36, 0.55);
}

h2 {
  font-size: 32px;
  color: #f3e4cb;
  margin-bottom: 10px;
}

.subtitle {
  font-size: 15px;
  color: var(--brass);
  margin-bottom: 16px;
}

.story, .end-desc {
  font-size: 14px;
  line-height: 1.75;
  color: #cec5b8;
  margin-bottom: 20px;
}

.warn-text {
  color: #f27474;
  font-weight: 700;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 14px;
  text-align: left;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 14px;
  margin-bottom: 22px;
}

.ctrl-item {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #dad2c5;
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  font-size: 11px;
  font-family: monospace;
  background: #231e1b;
  border: 1px solid #594b3b;
  border-radius: 4px;
  color: var(--brass);
}

.primary-btn {
  padding: 13px 34px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #160f0a;
  background: linear-gradient(180deg, #e7c27c 0%, #b9893d 100%);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(212, 170, 100, 0.32);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.primary-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.danger-btn {
  color: #fff;
  background: linear-gradient(180deg, #d6353d 0%, #8f141a 100%);
  box-shadow: 0 6px 20px rgba(184, 29, 36, 0.45);
}

.stats-box {
  margin: 16px auto 22px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.8;
  color: #e4dccf;
  max-width: 420px;
}
