* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: #000; overflow: hidden; }
body {
  color: #d8d2c8;
  font-family: "Shippori Mincho", "Yu Mincho", "Hiragino Mincho ProN", serif;
  user-select: none;
  -webkit-user-select: none;
}
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

.screen {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(0,0,0,.35) 0%, rgba(0,0,0,.88) 70%, #000 100%);
  animation: fadein 1.2s ease both;
}
.screen.light {
  background: radial-gradient(ellipse at center, rgba(255,255,255,.96) 0%, rgba(230,232,225,.94) 100%);
  color: #1a1a1a;
}
.screen .inner { padding: 24px 16px; max-width: 560px; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.sub { letter-spacing: .9em; padding-left: .9em; font-size: 13px; color: #8d857a; }
h1 {
  font-size: clamp(96px, 20vw, 190px); font-weight: 800; line-height: 1.05;
  color: #e9e2d6; letter-spacing: .08em; padding-left: .08em;
  text-shadow: 0 0 18px rgba(180, 10, 0, .75), 0 0 70px rgba(160, 0, 0, .55);
  animation: flicker 6s infinite;
}
h2 { font-size: clamp(54px, 10vw, 96px); font-weight: 800; letter-spacing: .14em; padding-left: .14em; }
h2.red { color: #b3120a; text-shadow: 0 0 30px rgba(200, 0, 0, .7); animation: shake .12s 6; }
.lead { margin: 18px 0 30px; font-size: 18px; line-height: 2; color: inherit; opacity: .85; }
@keyframes flicker {
  0%, 41%, 44%, 47%, 78%, 80%, 100% { opacity: 1; }
  42%, 46% { opacity: .35; }
  79% { opacity: .6; }
}
@keyframes shake {
  0% { transform: translate(0, 0); } 25% { transform: translate(-5px, 3px); }
  50% { transform: translate(4px, -3px); } 75% { transform: translate(-3px, -2px); }
  100% { transform: translate(0, 0); }
}

button {
  font: inherit; font-size: 20px; letter-spacing: .5em; padding: 14px 34px 14px calc(34px + .5em);
  color: #e9e2d6; background: rgba(20, 0, 0, .55);
  border: 1px solid rgba(190, 40, 30, .7); cursor: pointer;
  transition: background .25s, box-shadow .25s, color .25s;
}
button:hover, button:focus-visible {
  background: rgba(120, 8, 4, .8); color: #fff; outline: none;
  box-shadow: 0 0 28px rgba(200, 20, 10, .6);
}
.light button { color: #1a1a1a; background: rgba(255,255,255,.6); border-color: #555; }
.light button:hover { background: #1a1a1a; color: #fff; box-shadow: none; }

.howto { list-style: none; margin: 34px 0 14px; display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; font-size: 14px; color: #9b9388; }
.howto b { color: #d8d2c8; font-weight: 500; margin-right: 6px; letter-spacing: .1em; }
.hint { font-size: 13px; color: #7d766c; margin-top: 8px; }

#hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
#keys { position: absolute; left: 28px; bottom: 26px; display: flex; align-items: center; gap: 10px; font-size: 15px; letter-spacing: .3em; color: #a59c8e; }
#keys i {
  width: 12px; height: 12px; transform: rotate(45deg);
  border: 1px solid #8b7a45; opacity: .6; transition: all .5s;
}
#keys i.got { background: #f1c860; border-color: #ffe7a0; opacity: 1; box-shadow: 0 0 14px #f1c860; }
#stamina {
  position: absolute; left: 50%; bottom: 30px; width: 220px; height: 3px; margin-left: -110px;
  background: rgba(255,255,255,.12); opacity: 0; transition: opacity .5s;
}
#stamina.show { opacity: 1; }
#stamina-fill { height: 100%; width: 100%; background: #d8d2c8; transform-origin: left center; }
#stamina.low #stamina-fill { background: #c2251a; }
#message {
  position: absolute; left: 0; right: 0; top: 22%; text-align: center;
  font-size: 22px; letter-spacing: .4em; color: #e9e2d6; opacity: 0; transition: opacity .8s;
  text-shadow: 0 0 14px #000, 0 0 30px #000;
}
#message.show { opacity: .95; }

#loading { position: fixed; right: 18px; bottom: 14px; z-index: 20; font-size: 12px; color: #666; letter-spacing: .2em; }

#minimap { position: absolute; top: 50%; left: 50%; width: min(380px, 80vmin); height: min(380px, 80vmin); transform: translate(-50%, -50%); border-radius: 50%; opacity: 0; transition: opacity .25s; }
#minimap.show { opacity: 1; }
body.playing, body.playing * { cursor: none !important; }

#threat {
  position: absolute; top: 50%; left: 50%; width: 78vmin; height: 78vmin; border-radius: 50%;
  transform: translate(-50%, -50%); opacity: 0; transition: opacity .35s;
  background: conic-gradient(from -48deg, rgba(225,20,12,0) 0deg, rgba(225,20,12,.55) 28deg, rgba(240,30,18,.95) 48deg, rgba(225,20,12,.55) 68deg, rgba(225,20,12,0) 96deg, rgba(225,20,12,0) 360deg);
  -webkit-mask-image: radial-gradient(circle closest-side, transparent 64%, #000 80%, transparent 97%);
  mask-image: radial-gradient(circle closest-side, transparent 64%, #000 80%, transparent 97%);
  filter: blur(9px);
}

#timer {
  position: absolute; top: 20px; left: 0; right: 0; text-align: center;
  font-size: 17px; letter-spacing: .28em; color: #a59c8e; text-shadow: 0 0 10px #000;
  font-variant-numeric: tabular-nums; transition: color .6s;
}
#timer.danger { color: #d0281c; text-shadow: 0 0 14px rgba(200, 20, 10, .7); }

.buttons { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
button.ghost { font-size: 15px; letter-spacing: .3em; padding: 14px 22px 14px calc(22px + .3em); background: transparent; border-color: rgba(216,210,200,.35); color: #b8b0a4; }
button.ghost:hover, button.ghost:focus-visible { background: rgba(255,255,255,.08); border-color: rgba(216,210,200,.7); box-shadow: none; }
#tutorial {
  position: absolute; top: 58px; left: 50%; transform: translateX(-50%); width: min(620px, 92vw);
  padding: 14px 22px 16px; text-align: center; color: #f3efe6;
  background: rgba(12, 14, 18, .78); border: 1px solid rgba(240, 138, 36, .7); border-radius: 4px;
}
#tutorial.pop { animation: tutpop .5s ease; }
@keyframes tutpop { 0% { transform: translateX(-50%) scale(.94); border-color: #fff; } 100% { transform: translateX(-50%) scale(1); } }
#tut-count { font-size: 12px; letter-spacing: .3em; color: #f08a24; }
#tut-text { margin-top: 4px; font-size: 21px; letter-spacing: .12em; }
#tut-note { margin-top: 6px; font-size: 13.5px; line-height: 1.7; color: #c9c2b6; }
#clear #clear-text { font-size: 16px; }
#tutorial:not(.hidden) ~ #message { top: 52%; }

/* ---- かわいい画面（最初の画面・タイトル・練習中の案内） ---- */
.screen.cute {
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif; color: #6b5560;
  background: radial-gradient(ellipse at center, rgba(255,255,255,.1) 0%, rgba(255,226,233,.5) 75%, rgba(255,206,218,.75) 100%);
}
.screen.cute .card {
  background: rgba(255,255,255,.9); border: 4px solid #ffc2cf; border-radius: 34px;
  padding: 30px 38px 28px; box-shadow: 0 10px 0 rgba(255,150,170,.35), 0 24px 50px rgba(160,90,110,.25);
}
.screen.cute .sub { color: #ff8fa3; letter-spacing: .5em; padding-left: .5em; font-weight: 700; }
.screen.cute h1 {
  font-size: clamp(64px, 13vw, 116px); font-weight: 900; letter-spacing: .04em; padding: 0; line-height: 1.25;
  color: #ff6b81; text-shadow: 0 5px 0 #ffd23f, 0 9px 0 rgba(255,150,170,.4); animation: none;
}
.screen.cute h1 span { display: inline-block; animation: bounce 1.6s ease-in-out infinite; }
.screen.cute h1 span:nth-child(2) { animation-delay: .12s; color: #ff9f43; }
.screen.cute h1 span:nth-child(3) { animation-delay: .24s; color: #2ec4b6; }
.screen.cute h1 span:nth-child(4) { animation-delay: .36s; color: #7b8cff; }
.screen.cute h1 span:nth-child(5) { animation-delay: .48s; color: #ff6b81; }
@keyframes bounce { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-12px) rotate(3deg); } }
.screen.cute .lead { margin: 10px 0 22px; font-size: 18px; font-weight: 700; opacity: 1; line-height: 1.9; }
.screen.cute button {
  font-weight: 900; letter-spacing: .12em; padding: 14px 30px; border-radius: 999px;
  color: #fff; background: #ff6b81; border: none; box-shadow: 0 6px 0 #e04a63; transition: transform .1s, box-shadow .1s, background .2s;
}
.screen.cute button:hover, .screen.cute button:focus-visible { background: #ff8296; color: #fff; box-shadow: 0 6px 0 #e04a63; transform: translateY(-2px); }
.screen.cute button:active { transform: translateY(4px); box-shadow: 0 2px 0 #e04a63; }
.screen.cute button.ghost { font-size: 16px; color: #6b5560; background: #ffe9a8; box-shadow: 0 6px 0 #f0c85a; }
.screen.cute button.ghost:hover, .screen.cute button.ghost:focus-visible { background: #fff0c2; color: #6b5560; box-shadow: 0 6px 0 #f0c85a; border: none; }
.screen.cute .howto { margin: 26px 0 6px; gap: 10px 18px; color: #8d7681; font-weight: 700; }
.screen.cute .howto b { color: #fff; background: #7b8cff; border-radius: 8px; padding: 2px 8px; font-weight: 900; letter-spacing: .06em; }
.screen.cute .hint { color: #a08a95; font-weight: 700; margin-top: 12px; }

#tutorial {
  top: auto; bottom: 62px;
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif; font-weight: 700;
  color: #6b5560; background: rgba(255,255,255,.93); border: 4px solid #ffc2cf; border-radius: 26px;
  box-shadow: 0 7px 0 rgba(255,150,170,.35);
}
@keyframes tutpop { 0% { transform: translateX(-50%) scale(.92); border-color: #ffd23f; } 60% { transform: translateX(-50%) scale(1.03); } 100% { transform: translateX(-50%) scale(1); } }
#tut-count { color: #ff8fa3; font-weight: 900; }
#tut-text { color: #ff6b81; font-weight: 900; letter-spacing: .06em; }
#tut-note { color: #8d7681; }
#tutorial:not(.hidden) ~ #message { top: 22%; }
#tutorial:not(.hidden) ~ #stamina { bottom: 34px; }
.screen.cute h1 { font-size: clamp(50px, 8.5vw, 104px); white-space: nowrap; }

#lock-btn {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); pointer-events: auto;
  font-size: 18px; letter-spacing: .2em; padding: 18px 30px; color: #fff; background: rgba(10, 10, 12, .82);
  border: 1px solid rgba(255, 255, 255, .7); border-radius: 6px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .35);
}
#lock-btn:hover { background: rgba(40, 40, 46, .9); box-shadow: 0 0 0 9999px rgba(0, 0, 0, .35); color: #fff; }
body.needlock, body.needlock * { cursor: auto !important; }
body.needlock #lock-btn { cursor: pointer !important; }

#floor-card {
  position: fixed; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center;
  background: #000; color: #e9e2d6; font-size: clamp(64px, 12vw, 130px); font-weight: 800; letter-spacing: .2em; padding-left: .2em;
  text-shadow: 0 0 30px rgba(180, 10, 0, .6); opacity: 0; pointer-events: none; transition: opacity .7s;
}
#floor-card.show { opacity: 1; }

#over .inner { max-width: 640px; }
#over h2 { font-size: clamp(38px, 6vw, 60px); }
#over .lead { margin: 8px 0 14px; font-size: 16px; }
#replay { display: block; margin: 0 auto; width: min(440px, 52vh, 86vw); height: min(440px, 52vh, 86vw); border: 1px solid rgba(216,210,200,.25); transition: border-color .3s, box-shadow .3s; }
#replay.tense { border-color: rgba(230,40,25,.9); box-shadow: 0 0 26px rgba(220,30,15,.45); }
#replay-track { width: min(440px, 52vh, 86vw); height: 2px; margin: 8px auto 0; background: rgba(255,255,255,.12); }
#replay-bar { height: 100%; background: #b3120a; transform-origin: left center; transform: scaleX(0); }
#replay-info { margin: 8px 0 16px; letter-spacing: .2em; font-variant-numeric: tabular-nums; color: #a59c8e; }

#sens-box { margin-top: 26px; padding: 16px 22px; border: 1px solid rgba(216,210,200,.25); display: inline-block; cursor: default; }
#sens-box label { display: block; font-size: 15px; letter-spacing: .2em; margin-bottom: 10px; }
#sens-box b { color: #fff; font-variant-numeric: tabular-nums; }
#sens-range { width: 260px; accent-color: #b3120a; cursor: pointer; }
#sens-toast { position: absolute; right: 26px; bottom: 26px; font-size: 14px; letter-spacing: .2em; color: #d8d2c8; opacity: 0; transition: opacity .4s; text-shadow: 0 0 10px #000; }
#sens-toast.show { opacity: .9; }
#tut-sens { margin-top: 8px; font-size: 13px; color: #7b8cff; font-weight: 900; }
#tut-sens kbd { font-family: inherit; color: #fff; background: #7b8cff; border-radius: 6px; padding: 1px 7px; }
#tut-sens b { color: #ff6b81; font-size: 16px; font-variant-numeric: tabular-nums; }
