:root {
  --bg-1: #2b0308;
  --bg-2: #59070e;
  --bg-3: #8f170f;
  --card: rgba(35, 5, 10, 0.86);
  --line: rgba(255, 255, 255, 0.22);
  --text: #fff5f1;
  --muted: #ffd6ce;
  --accent: #ffe087;
  --accent-2: #ffb021;
  --good: #72e06a;
  --warn: #ffe6bf;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  font-family: "Segoe UI", "Yu Gothic UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 8% 10%, #ff6b3b, transparent 34%),
    radial-gradient(circle at 88% 78%, #ad1116, transparent 44%),
    radial-gradient(circle at 54% 96%, #ffbb33, transparent 30%),
    linear-gradient(145deg, var(--bg-1), var(--bg-2) 58%, var(--bg-3));
  overflow: hidden;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url("../assets/tsumugi.png") no-repeat 8% -3%,
    url("../assets/tsumugi.png") no-repeat -20% 84%;
  background-size: min(1020px, 124vw), min(340px, 46vw);
  opacity: 0.44;
  transform: rotate(-2deg);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    112deg,
    rgba(255, 220, 180, 0.06) 0 2px,
    transparent 2px 15px
  );
  pointer-events: none;
  z-index: 0;
}

.slot-app {
  width: min(980px, 96vw);
  display: grid;
  gap: 12px;
  padding: 8px 0;
  position: relative;
  z-index: 1;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(7, 14, 30, 0.82);
  backdrop-filter: blur(7px);
}

.topbar {
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.voice-state-row {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.voice-state {
  font-size: 0.76rem;
  color: #ffe6a8;
  flex: 1;
}

.voice-settings-btn {
  padding: 2px 7px;
  font-size: 0.78rem;
  border-radius: 7px;
  flex: 0 0 auto;
  font-weight: 400;
}

/* ── Voice Settings Dialog ── */
.voice-settings-dialog {
  background: rgba(14, 4, 6, 0.97);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  padding: 20px 24px;
  max-width: min(480px, 92vw);
  width: 100%;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.7);
}

.voice-settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(4px);
}

.voice-settings-dialog h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  color: var(--accent);
}

.dialog-hint {
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 14px;
}

.dialog-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--muted);
}

.dialog-input {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 0.85rem;
  width: 100%;
}

.dialog-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.dialog-input:focus {
  outline: none;
  border-color: var(--accent-2);
}

.dialog-current {
  font-size: 0.73rem;
  color: #ffe6a8;
  margin: 6px 0 0;
  min-height: 1em;
}

.dialog-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  justify-content: flex-end;
}

.btn-primary {
  background: linear-gradient(102deg, var(--accent), var(--accent-2));
  color: #2a1800;
  border-color: transparent;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.1rem, 2.1vw, 1.45rem);
}

h2 {
  font-size: 0.9rem;
}

.sub {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 3px;
}

.character {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 48%;
}

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--line);
  flex: 0 0 auto;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#charaLine {
  font-size: 0.79rem;
  color: var(--warn);
  line-height: 1.35;
}

.play-area {
  display: grid;
  grid-template-columns: 1fr 210px;
  gap: 12px;
}

.machine {
  padding: 12px;
  display: grid;
  gap: 10px;
}

.status {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.status > div {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.06);
}

.label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
}

.status strong {
  font-size: clamp(1.05rem, 2.8vw, 1.4rem);
}

.reels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.reel {
  min-height: 112px;
  border-radius: 12px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: clamp(2.15rem, 8vw, 3.3rem);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(0, 0, 0, 0.2));
  transition: transform 130ms ease, box-shadow 130ms ease;
}

.controls {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

button {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  font-weight: 700;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.17);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button.spin {
  border-color: transparent;
  background: linear-gradient(102deg, var(--accent), var(--accent-2));
  color: #2a1800;
}

.message {
  border-radius: 10px;
  border: 1px solid var(--line);
  min-height: 44px;
  padding: 10px;
  font-size: 0.92rem;
  display: grid;
  align-items: center;
  background: rgba(25, 0, 0, 0.36);
}

.message.win {
  color: var(--good);
}

.guide {
  padding: 10px;
  display: grid;
  gap: 8px;
  align-content: start;
}

#payTable {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

#payTable li {
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 5px 9px;
  font-size: 0.76rem;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.hint {
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.4;
}

.win-fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
}

.win-fx.active {
  animation: screenFlash 580ms ease-out;
}

.win-fx .spark {
  position: absolute;
  width: 10px;
  height: 18px;
  border-radius: 999px;
  animation: burst 950ms ease-out forwards;
  box-shadow: 0 0 10px currentColor;
}

.jackpot-banner {
  position: fixed;
  top: 9%;
  left: 50%;
  transform: translateX(-50%) scale(0.7);
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(10, 20, 38, 0.82);
  background: rgba(66, 9, 12, 0.92);
  color: #ffe389;
  border-radius: 999px;
  padding: 10px 22px;
  font-weight: 800;
  letter-spacing: 0.07em;
  opacity: 0;
  pointer-events: none;
  z-index: 4;
}

.jackpot-banner.show {
  animation: bannerPop 1000ms ease-out;
}

.jackpot-banner.lose {
  background: rgba(30, 35, 52, 0.9);
  color: #d8e3ff;
  border-color: rgba(190, 205, 255, 0.45);
}

.reel.win-pop {
  animation: reelPop 360ms ease-out;
  box-shadow: 0 0 30px rgba(255, 218, 113, 0.44);
}

body.win-mode .slot-app {
  animation: pulseBoard 620ms ease-out;
}

@keyframes burst {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--move-x), var(--move-y)) rotate(220deg) scale(0.2);
    opacity: 0;
  }
}

@keyframes screenFlash {
  0% { background: rgba(255, 255, 255, 0.25); }
  100% { background: rgba(255, 255, 255, 0); }
}

@keyframes bannerPop {
  0% {
    opacity: 0;
    transform: translateX(-50%) scale(0.66);
  }
  30% {
    opacity: 1;
    transform: translateX(-50%) scale(1.06);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) scale(0.96);
  }
}

@keyframes reelPop {
  0% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-7px) scale(1.07); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes pulseBoard {
  0% { transform: scale(1); }
  40% { transform: scale(1.014); }
  100% { transform: scale(1); }
}

/* ── Win Streak Section ── */
.streak-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  transition: background 0.3s, border-color 0.3s;
}

.streak-section.streak-active {
  background: rgba(255, 224, 102, 0.07);
  border-color: rgba(255, 200, 60, 0.4);
}

.streak-section.streak-hot {
  background: rgba(255, 100, 30, 0.1);
  border-color: rgba(255, 120, 30, 0.6);
  animation: streakPulse 1.2s ease-in-out infinite;
}

.streak-info {
  border-radius: 10px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
}

.streak-guide {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  font-size: 0.68rem;
  color: var(--muted);
  flex-wrap: wrap;
  padding: 2px 0 0;
}

.streak-multiplier {
  font-size: clamp(1.05rem, 2.8vw, 1.4rem);
  color: var(--accent);
}

.streak-multiplier.streak-x1-5 {
  color: #ffe066;
}

.streak-multiplier.streak-x2 {
  color: var(--accent-2);
  text-shadow: 0 0 8px rgba(255, 176, 33, 0.5);
}

.streak-multiplier.streak-x3 {
  color: #ff6b3b;
  text-shadow: 0 0 12px rgba(255, 100, 30, 0.7);
}

@keyframes streakPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 120, 30, 0); }
  50%       { box-shadow: 0 0 12px 3px rgba(255, 120, 30, 0.35); }
}

@media (max-width: 900px) {
  .play-area {
    grid-template-columns: 1fr;
  }

  .guide {
    padding: 9px;
  }

  #payTable {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  #payTable li {
    width: auto;
  }
}

@media (max-width: 932px) and (orientation: landscape) {
  body {
    min-height: 100dvh;
  }

  body::before {
    background: url("../assets/tsumugi.png") no-repeat 4% -8%,
      url("../assets/tsumugi.png") no-repeat -30% 84%;
    background-size: min(860px, 138vw), min(220px, 42vw);
    opacity: 0.53;
    transform: rotate(-1deg);
  }

  body::after {
    opacity: 0.55;
  }

  .panel {
    background: rgba(33, 6, 9, 0.72);
  }

  .slot-app {
    width: min(960px, 98vw);
    gap: 8px;
  }

  .topbar {
    padding: 8px 10px;
  }

  .sub {
    font-size: 0.75rem;
  }

  .character {
    max-width: 54%;
  }

  #charaLine {
    font-size: 0.72rem;
  }

  .play-area {
    grid-template-columns: 1fr 190px;
    gap: 8px;
  }

  .machine {
    gap: 7px;
    padding: 8px;
  }

  .status > div {
    padding: 6px 8px;
  }

  .reel {
    min-height: 76px;
    font-size: clamp(1.8rem, 5vw, 2.4rem);
  }

  .controls {
    grid-template-columns: 0.8fr 0.8fr 1.25fr 0.8fr 1fr;
  }

  button {
    padding: 8px;
    font-size: 0.84rem;
  }

  .message {
    min-height: 36px;
    padding: 7px 9px;
    font-size: 0.82rem;
  }

  .guide {
    padding: 8px;
    gap: 6px;
  }

  #payTable li {
    font-size: 0.7rem;
    padding: 4px 8px;
  }

  .hint {
    font-size: 0.68rem;
  }
}

/* ゲームオーバー演出 */
.game-over-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: gameOverFadeIn 0.8s ease forwards;
}

.game-over-overlay.hidden {
  display: none;
}

@keyframes gameOverFadeIn {
  0% { background: rgba(0, 0, 0, 0); }
  100% { background: rgba(0, 0, 0, 0.85); }
}

.game-over-content {
  text-align: center;
  animation: gameOverSlideIn 0.6s ease 0.3s both;
}

@keyframes gameOverSlideIn {
  0% { opacity: 0; transform: scale(0.8) translateY(20px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.game-over-title {
  font-size: 3rem;
  font-weight: 900;
  color: #ff2244;
  text-shadow: 0 0 30px rgba(255, 34, 68, 0.6), 0 0 60px rgba(255, 34, 68, 0.3);
  letter-spacing: 0.15em;
  margin-bottom: 1.2rem;
  font-family: "Kanit", "Segoe UI", sans-serif;
}

.game-over-line {
  font-size: 1.1rem;
  color: #ffaaaa;
  margin-bottom: 2rem;
  min-height: 1.5em;
}

.game-over-btn {
  font-size: 1.3rem;
  font-weight: 700;
  padding: 14px 48px;
  border: 2px solid #ff4466;
  border-radius: 12px;
  background: transparent;
  color: #ff4466;
  cursor: pointer;
  letter-spacing: 0.1em;
  animation: gameOverBtnPulse 1.5s ease-in-out infinite;
  transition: background 0.2s, color 0.2s;
}

.game-over-btn:hover,
.game-over-btn:active {
  background: #ff4466;
  color: #fff;
}

@keyframes gameOverBtnPulse {
  0%, 100% { box-shadow: 0 0 10px rgba(255, 68, 102, 0.3); }
  50% { box-shadow: 0 0 25px rgba(255, 68, 102, 0.6); }
}

@media (max-width: 560px) and (orientation: portrait) {
  body::before {
    background: url("../assets/tsumugi.png") no-repeat 8% -4%;
    background-size: min(760px, 200vw);
    opacity: 0.5;
    transform: none;
  }

  body::after {
    opacity: 0.48;
  }

  .panel {
    background: rgba(33, 6, 9, 0.66);
  }

  .topbar {
    display: grid;
    gap: 7px;
  }

  .character {
    max-width: 100%;
  }

  .controls {
    grid-template-columns: repeat(3, 1fr);
  }
}
