/* ==========================================================
   魂のポーカー — 暗いカジノの画面のまわり（文字・ボタン）
   ========================================================== */

:root {
  --ink: #e8d9c0;
  --dim: #9c8a72;
  --blood: #a3141a;
  --blood-dark: #4a0a0c;
  --gold: #c9a45c;
  --panel: rgba(8, 3, 3, .72);
  /* ふだんの文字（ボタン・数字・説明）：かしこまった明朝 */
  --font-ja: "Zen Old Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  /* 死神のセリフ・見出しの日本語：明朝（lowres.js で粗い画像にする） */
  --font-horror: "Zen Old Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #030101;
  color: var(--ink);
  font-family: var(--font-ja);
  -webkit-tap-highlight-color: transparent;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated; /* わざと粗くして、昔のホラーゲームっぽく */
  touch-action: manipulation;
}

/* 画面のふちを暗く。魂が減ると赤くなる */
.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, .85) 100%);
  transition: background .6s;
}
.vignette.is-danger {
  animation: pulse 1s infinite;
  background: radial-gradient(ellipse at center, transparent 35%, rgba(110, 0, 0, .75) 100%);
}
.vignette.is-flash { background: rgba(140, 0, 0, .45); transition: none; }
@keyframes pulse { 50% { opacity: .55; } }

/* 上の表示 */
.hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px 16px;
  flex-wrap: wrap;
  padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: linear-gradient(rgba(0, 0, 0, .8), transparent);
  font-size: 14px;
}
.hud__item b { color: var(--gold); font-size: 18px; margin-left: 4px; }
.hud__item--pot b { color: #e0503c; }
.hud__rate { flex-basis: 100%; text-align: center; font-size: 12px; color: var(--dim); letter-spacing: .08em; }
.hud__rate:empty { display: none; }
.hud__rate.is-boost { color: #ff4a3a; font-size: 15px; font-weight: 700; text-shadow: 0 0 8px #900; animation: pulse 1s infinite; }
.hud__back { position: absolute; left: 12px; color: var(--dim); text-decoration: none; font-size: 13px; }
.hud__mute {
  position: absolute; right: 10px;
  background: none; border: 0; font-size: 18px; cursor: pointer; opacity: .8;
}
@media (max-width: 560px) {
  .hud { gap: 4px 10px; padding-top: max(34px, env(safe-area-inset-top)); font-size: 12px; }
  .hud__back, .hud__mute { top: 6px; }
  .hud__item b { font-size: 15px; }
}

/* 死神のセリフ */
.say {
  position: fixed;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  width: min(90vw, 560px);
  margin: 0;
  text-align: center;
  font-size: clamp(18px, 4.2vw, 24px);
  letter-spacing: .12em;
  color: #f0c8b8;
  text-shadow: 0 0 8px #8a0000, 0 0 2px #000;
  font-family: var(--font-horror);
  font-weight: 700;
  opacity: 0;
  transition: opacity .5s;
  pointer-events: none;
}
.say.is-show { opacity: 1; }

/* 下の表示とボタン */
.bottom {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 10px 12px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  text-align: center;
  pointer-events: none;
}
.bottom__hand, .bottom__prompt {
  margin: 0 auto 6px;
  width: fit-content;
  max-width: 94vw;
  padding: 2px 12px;
  border-radius: 4px;
  background: var(--panel);
  font-size: 14px;
}
.bottom__hand:empty, .bottom__prompt:empty { display: none; }
.bottom__hand { color: var(--gold); font-weight: 700; }
.bottom__prompt { color: var(--ink); }

.controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  pointer-events: auto;
}

.btn {
  min-width: 120px;
  padding: 10px 18px;
  border: 1px solid #6b1a1a;
  border-radius: 4px;
  background: linear-gradient(#2a0b0b, #150505);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  letter-spacing: .08em;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(120, 0, 0, .35);
  transition: background .2s, transform .1s;
}
.btn:hover { background: linear-gradient(#3c0f0f, #1d0606); }
.btn:active { transform: translateY(1px); }
.btn--main { border-color: var(--blood); background: linear-gradient(#6a0f12, #340607); }
.btn--main:hover { background: linear-gradient(#83141a, #420809); }

/* はじめの画面・終わりの画面 */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, .78);
  z-index: 10;
}
.overlay[hidden] { display: none; }
.overlay__box {
  width: min(100%, 520px);
  max-height: 100%;
  overflow: auto;
  padding: 24px 20px;
  border: 1px solid var(--blood-dark);
  background: rgba(12, 4, 4, .92);
  text-align: center;
  box-shadow: 0 0 40px rgba(120, 0, 0, .4);
}
.overlay__title {
  margin: 0 0 12px;
  font-family: var(--font-horror);
  font-weight: 700;
  font-size: clamp(26px, 7vw, 38px);
  letter-spacing: .25em;
  color: #d8262c;
  text-shadow: 0 0 14px #600;
}
.overlay__title .t {
  display: block;
  font-size: clamp(30px, 9vw, 48px);
  letter-spacing: .2em;
  line-height: 1.4;
}
.overlay__text { margin: 0 0 14px; font-size: 14px; line-height: 1.9; color: var(--ink); }
.overlay__rules {
  margin: 0 0 18px;
  padding: 10px 14px 10px 28px;
  text-align: left;
  font-size: 13px;
  line-height: 1.8;
  color: var(--dim);
  border-top: 1px solid #2a0c0c;
  border-bottom: 1px solid #2a0c0c;
}
.overlay__note { margin: 10px 0 0; font-size: 12px; color: var(--dim); }

/* 粗い画像にした文字（lowres.js）：ドットのまま拡大する */
canvas.lowres {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
@supports (image-rendering: pixelated) { canvas.lowres { image-rendering: pixelated; } }

/* 死神を倒したとき */
.stamp {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 9;
}
.stamp span {
  /* 枠はつけず、文字のうしろに、ふちが闇にとける暗いもやを置く */
  width: 100%;
  padding: 40px 0;
  background: radial-gradient(ellipse 50% 50% at center, rgba(0, 0, 0, .85), rgba(0, 0, 0, .5) 55%, transparent 100%);
  font-family: var(--font-horror);
  text-align: center;
  color: #fff3d0;
  text-shadow: 0 0 18px #ffcf6a, 0 0 40px #b07a20;
  animation: stamp 3.6s ease-out forwards;
}
.stamp .t {
  display: block;
  font-weight: 700;
  font-size: clamp(36px, 11vw, 84px);
  letter-spacing: .3em;
  color: #fff3d0;
}
.stamp--lose span {
  text-shadow: 0 0 18px #c00000, 0 0 40px #600000;
  animation-duration: 4.6s;
}
.stamp--lose .t { color: #ff6a58; }

/* 負けたとき、画面をだんだん真っ暗にする幕（大きな文字・リザルト画面より下） */
.fade-black {
  position: fixed;
  inset: 0;
  z-index: 8;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.5s ease-in;
}
.fade-black.is-on { opacity: 1; transition: opacity 3s ease-in; }

@keyframes stamp {
  0% { opacity: 0; transform: scale(2.6); filter: blur(6px); }
  12% { opacity: 1; transform: scale(.94); filter: blur(0); }
  18% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.06); }
}

.overlay--win { background: radial-gradient(ellipse at 50% 30%, rgba(120, 150, 190, .35), rgba(0, 0, 0, .82) 70%); }
.overlay--win .overlay__box {
  border-color: #8a7038;
  background: rgba(14, 12, 10, .92);
  box-shadow: 0 0 50px rgba(240, 200, 110, .3);
  animation: rise .9s ease-out;
}
.overlay--win .overlay__title { color: #f2d58a; text-shadow: 0 0 16px #b07a20; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
.overlay__badge {
  display: inline-block;
  margin: 0 0 10px;
  padding: 2px 14px;
  border: 1px solid #8a7038;
  border-radius: 999px;
  color: #f2d58a;
  font-size: 14px;
  letter-spacing: .12em;
}
.overlay__stats { display: grid; gap: 4px; margin: 0 auto 18px; max-width: 320px; font-size: 13px; }
.overlay__stats div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed #3a2a1a; padding: 2px 0; }
.overlay__stats dt { color: var(--dim); }
.overlay__stats dd { margin: 0; color: var(--gold); font-weight: 700; }
.overlay__btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.btn--share {
  display: inline-block;
  border-color: #555;
  background: linear-gradient(#1c1c1c, #050505);
  text-decoration: none;
}
.btn--share:hover { background: linear-gradient(#2c2c2c, #111); }
