/*
  最強の2択（さいきょうの2たく） だけの みため
  （いろなどの きほんは ../common/common.css に ある）
*/

/* ふりがなが ながくても、かんじの あいだを あけない */
.game-title ruby {
  ruby-align: center;
}

/* ===== がめん1: せってい ===== */
.setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 20px 32px;
}

/* あそびかた */
.rule {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-medium);
  background: #f1effb;
  word-break: keep-all; /* ことばの とちゅうで おりかえさない */
}

.rule-text {
  margin: 0 0 4px;
  font-size: 1.1rem;
  text-align: center;
}

.rule-list {
  margin: 0;
  padding-left: 1.2em;
  font-size: 0.9rem;
  color: var(--color-text-sub);
}

.setting {
  width: 100%;
}

.setting-title {
  margin: 0 0 12px;
  font-size: 1.15rem;
  text-align: center;
}

.setting-note {
  margin: 8px 0 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--color-text-sub);
  text-align: center;
}

/* かいすうの − ＋（数当てと おなじ かたち） */
.goal-view {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.goal-button {
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 4px 0 var(--color-accent-dark);
  color: #fff;
  font-family: inherit;
  font-size: 1.8rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.goal-button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--color-accent-dark);
}

.goal-button:disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
}

.goal-button:focus-visible {
  outline: 3px solid var(--color-yellow);
  outline-offset: 3px;
}

.goal-label {
  min-width: 4.5em;
  margin: 0;
  font-size: 1.2rem;
  text-align: center;
}

.goal-value {
  margin-right: 4px;
  font-size: 2.6rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.setup-best {
  margin: 0;
  padding: 8px 18px;
  border-radius: 999px;
  background: #f1effb;
  font-size: 0.95rem;
  color: var(--color-text-sub);
  text-align: center;
}

.setup-best span {
  color: var(--color-text);
}

/* ===== がめん2: あそぶ ===== */
.play {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 560px;
  margin: 0 auto;
}

/* へや・ちょうせん・ベスト */
.hud {
  display: flex;
  gap: 8px;
  width: 100%;
}

.hud-item {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 6px 4px;
  border-radius: var(--radius-medium);
  background: rgba(255, 255, 255, 0.1);
}

.hud-label {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.75);
  white-space: nowrap;
}

.hud-value {
  font-size: 1.4rem;
  font-weight: 900;
  line-height: 1.3;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.hud-value--small {
  font-size: 1.1rem;
}

.hud-item--best .hud-label {
  color: var(--color-yellow);
}

/* すすみぐあいの マス */
.path {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}

.step {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.16);
  transition: background 0.3s, transform 0.3s;
}

.step--done {
  background: var(--color-accent);
}

.step--now {
  background: var(--color-yellow);
  transform: scale(1.25);
}

/* ゴールの ★ */
.step--goal {
  width: 24px;
  height: 24px;
  background: transparent;
  color: rgba(255, 210, 63, 0.45);
  font-size: 1.2rem;
  line-height: 24px;
  text-align: center;
}

.step--goal.step--done {
  color: var(--color-yellow);
  transform: scale(1.3);
}

/* ===== へや ===== */
/* へやの おきば（のこりの たかさを ぜんぶ もらう） */
.stage-area {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 140px;
  container-type: size;
}

.stage {
  --room-h: 245; /* かべの いろ（main.js で かえる） */
  position: relative;
  /* おきばの はば と たかさの どちらにも おさまる おおきさに する */
  width: min(100cqw, 100cqh * 4 / 3);
  aspect-ratio: 4 / 3;
  border-radius: 20px;
  overflow: hidden;
  background: #000;
  box-shadow: var(--shadow);
}

.room {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12%;
  padding-bottom: 14%;
  /* かべ と ゆか */
  background:
    linear-gradient(180deg, transparent 72%, rgba(0, 0, 0, 0.25) 72%, rgba(0, 0, 0, 0.45) 100%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0 2px, transparent 2px 40px),
    linear-gradient(180deg, hsl(var(--room-h) 45% 38%), hsl(var(--room-h) 50% 24%));
  transform-origin: 50% 60%;
}

.room-name {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  font-size: 0.9rem;
  white-space: nowrap;
}

/* たいまつ（へやの かざり） */
.torch {
  position: absolute;
  top: 22%;
  width: 10px;
  height: 34px;
  border-radius: 3px;
  background: #6b4a2e;
}

.torch::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -18px;
  width: 18px;
  height: 22px;
  transform: translateX(-50%);
  border-radius: 50% 50% 45% 45%;
  background: radial-gradient(circle at 50% 70%, #fff6c9, var(--color-yellow) 45%, var(--color-main) 80%);
  box-shadow: 0 0 24px 8px rgba(255, 170, 60, 0.45);
  animation: flicker 1.2s ease-in-out infinite alternate;
}

.torch--left {
  left: 8%;
}

.torch--right {
  right: 8%;
}

/* ===== とびら ===== */
.door {
  position: relative;
  width: 28%;
  aspect-ratio: 1 / 1.75;
  padding: 0;
  border: none;
  background: none;
  perspective: 700px;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.door:disabled {
  cursor: default;
}

.door:focus-visible {
  outline: 3px solid var(--color-yellow);
  outline-offset: 8px;
}

.door-frame {
  position: absolute;
  inset: -6% -10% 0;
  border-radius: 999px 999px 0 0;
  background: linear-gradient(180deg, #8a8fa8, #565b78);
  box-shadow: inset 0 0 0 4px rgba(0, 0, 0, 0.25);
}

/* とびらの むこう（あたりでも はずれでも おなじ ひかりに みせる） */
.door-inside {
  position: absolute;
  inset: 0;
  border-radius: 999px 999px 0 0;
  overflow: hidden;
  background: radial-gradient(circle at 50% 55%, #fffbe6, #ffe28a 40%, #ff9e3d 100%);
}

/* とびらの いた（ひだりの ちょうつがいを じくに てまえへ ひらく） */
.door-panel {
  position: absolute;
  inset: 0;
  border-radius: 999px 999px 0 0;
  transform-origin: 0% 50%;
  transition: transform 0.75s cubic-bezier(0.3, 0.1, 0.25, 1);
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.12) 0 3px, transparent 3px 22%),
    linear-gradient(180deg, #b0703a, #7d4a22);
  box-shadow: inset 0 0 0 5px rgba(0, 0, 0, 0.2), 0 6px 12px rgba(0, 0, 0, 0.3);
  backface-visibility: hidden;
}

.door-knob {
  position: absolute;
  right: 12%;
  top: 55%;
  width: 12%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff6c9, var(--color-yellow) 60%, #b88a00);
}

.door-letter {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  font-size: clamp(1rem, 5vw, 1.5rem);
  font-weight: 900;
  color: rgba(255, 255, 255, 0.85);
}

.door--open .door-panel {
  transform: rotateY(-105deg);
}

/* つぎの へやの とびらは、さいしょから しまった じょうたいで だす（しまる うごきを みせない） */
.door--instant .door-panel {
  transition: none;
}

/* パソコンで マウスを のせると、すこしだけ ひらきかける */
@media (hover: hover) {
  .door:not(:disabled):hover .door-panel {
    transform: rotateY(-8deg);
  }
}

/* ===== なかへ すすむ（とびらの いちを まんなかに して すいこまれる） ===== */
.stage--enter .room {
  transition: transform 0.9s cubic-bezier(0.55, 0, 0.8, 0.4), filter 0.9s;
  transform: scale(4.2);
  filter: brightness(1.8);
}

.flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: #fffbe6;
  opacity: 0;
}

.stage--enter .flash {
  transition: opacity 0.5s 0.45s;
  opacity: 1;
}

/* つぎの へやが あらわれる */
.room--arrive {
  animation: arrive 0.6s ease-out;
}

/* いりぐちの へやに もどってくる */
.room--return {
  animation: return-in 0.7s cubic-bezier(0.2, 0.8, 0.3, 1.2);
}

/* ===== はずれの へや ===== */
.miss-scene {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: radial-gradient(circle at 50% 50%, #3a2d6b, #120f33 70%);
  text-align: center;
  animation: fade-in 0.35s ease-out;
}

.miss-title {
  margin: 0;
  font-size: clamp(1.6rem, 7vw, 2.4rem);
  font-weight: 900;
  color: var(--color-pink);
}

.miss-text {
  margin: 0;
  color: rgba(255, 255, 255, 0.75);
}

/* うずまき（いりぐちへ すいこまれる） */
.swirl {
  width: 26%;
  max-width: 120px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #7b4dff, var(--color-accent), var(--color-pink), #7b4dff);
  -webkit-mask: radial-gradient(circle, transparent 28%, #000 30%);
  mask: radial-gradient(circle, transparent 28%, #000 30%);
  animation: spin 0.9s linear infinite;
}

.miss-scene--leave {
  animation: suck 0.6s ease-in forwards;
}

/* ===== たからものの へや ===== */
.treasure {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  background: radial-gradient(circle at 50% 60%, #ffe28a, #ff9e3d 55%, #b0482a);
  color: var(--color-text);
  text-align: center;
  animation: arrive 0.7s ease-out;
}

.chest {
  width: 36%;
  max-width: 180px;
}

.treasure-title {
  margin: 0;
  font-size: clamp(1.6rem, 7vw, 2.4rem);
  font-weight: 900;
  line-height: 1.2;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}

.treasure-text {
  margin: 0;
  font-size: clamp(0.9rem, 3.6vw, 1.05rem);
  line-height: 1.5;
}

/* ===== メッセージ ===== */
.message {
  min-height: 1.6em;
  margin: 0;
  font-size: 1.05rem;
  text-align: center;
}

.message--miss {
  color: var(--color-pink);
}

.message--hit {
  color: var(--color-yellow);
}

/* ===== クリアしたとき ===== */
.clear-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 20px 20px 24px;
  text-align: center;
  animation: pop-in 0.4s cubic-bezier(0.3, 1.5, 0.6, 1);
}

.new-record {
  margin: 0;
  padding: 4px 16px;
  border-radius: 999px;
  background: var(--color-pink);
  color: #fff;
  animation: pop-in 0.5s 0.2s both;
}

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

/* きょうしつへの ボタン（ほかの ゲームと おなじ みため） */
.studio-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
  margin-top: 4px;
  padding: 14px 16px;
  border: 3px dashed #c9c5ee;
  border-radius: var(--radius-medium);
  background: #faf9ff;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.studio-button:hover {
  border-color: var(--color-accent);
  background: #eef9ff;
}

.studio-button-main {
  font-size: 1.05rem;
  color: var(--color-text);
}

.studio-button-sub {
  font-size: 0.85rem;
  color: var(--color-accent-dark);
}

.play-buttons {
  display: flex;
  justify-content: center;
}

/* ===== うごき ===== */
@keyframes flicker {
  from { transform: translateX(-50%) scale(1); }
  to { transform: translateX(-50%) scale(1.12, 0.92); }
}

@keyframes arrive {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes suck {
  to { opacity: 0; transform: scale(0.1) rotate(200deg); }
}

@keyframes return-in {
  from { opacity: 0; transform: scale(0.3) rotate(-25deg); }
  to { opacity: 1; transform: none; }
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.7); }
}

/* ===== ちいさい がめん（スマホ）===== */
/* スクロール しないで 1がめんに おさまるように つめる */
@media (max-width: 600px) {
  .rule {
    padding: calc(8px + var(--spare) * 6 / 190) 12px;
  }

  .rule-text {
    font-size: calc(1rem + var(--spare) * 1.6 / 190);
  }

  .rule-list {
    font-size: calc(0.82rem + var(--spare) * 1.28 / 190);
    line-height: calc(1.4rem + var(--spare) * 3.2 / 190);
  }

  .goal-button {
    width: calc(48px + var(--spare) * 8 / 190);
    height: calc(48px + var(--spare) * 8 / 190);
    font-size: 1.6rem;
  }

  .goal-value {
    font-size: calc(2.2rem + var(--spare) * 6.4 / 190);
  }

  .play {
    gap: calc(8px + var(--spare) * 8 / 190);
  }

  .hud-item {
    padding: calc(2px + var(--spare) * 6 / 190) 4px;
  }

  .hud-label {
    font-size: calc(0.72rem + var(--spare) * 1.28 / 190);
  }

  .path {
    gap: 6px;
    min-height: 22px;
  }

  .message {
    font-size: calc(0.95rem + var(--spare) * 1.6 / 190);
  }

  .clear-box {
    gap: calc(8px + var(--spare) * 6 / 190);
    padding: calc(12px + var(--spare) * 8 / 190) 14px calc(14px + var(--spare) * 8 / 190);
  }

  .studio-button {
    margin-top: 0;
    padding: calc(8px + var(--spare) * 6 / 190) 12px;
  }

  .play-buttons .btn {
    padding: 6px 16px;
    font-size: calc(0.9rem + var(--spare) * 1.6 / 190);
  }
}

@media (max-width: 400px) {
  .hud-value {
    font-size: 1.2rem;
  }

  .hud-value--small {
    font-size: 1rem;
  }

  .room-name {
    top: 6px;
    font-size: 0.8rem;
  }
}
