@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700&family=Sora:wght@400;500;600;700&display=swap');

:root {
  color-scheme: dark;
  --bg-1: #3a0f2a;
  --bg-2: #5a1844;
  --bg-3: #260a20;
  --card: rgba(54, 12, 43, 0.74);
  --card-soft: rgba(255, 255, 255, 0.08);
  --text: #fff3ff;
  --muted: #f2c0dc;
  --line: rgba(255, 174, 218, 0.3);
  --glow-1: rgba(255, 120, 196, 0.38);
  --glow-2: rgba(255, 151, 215, 0.34);
  --accent: #ff78d8;
  --accent-strong: #ff4eb5;
  --danger: #ff9ac7;
  --shadow: rgba(32, 7, 25, 0.52);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  position: relative;
  overflow-x: hidden;
  color: var(--text);
  font-family: 'Sora', 'Noto Sans Thai', system-ui, sans-serif;
  background:
    radial-gradient(700px 480px at 12% 8%, var(--glow-1), transparent 66%),
    radial-gradient(720px 520px at 85% 6%, var(--glow-2), transparent 62%),
    linear-gradient(145deg, var(--bg-1) 6%, var(--bg-2) 52%, var(--bg-3));
}

.kuromi-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.kuromi-layer {
  position: absolute;
  opacity: 0.2;
  filter: blur(0.4px) saturate(1.1);
  mix-blend-mode: screen;
  animation: kuromiDrift 16s ease-in-out infinite alternate;
}

.kuromi-layer-a {
  width: min(30vw, 420px);
  left: -4vw;
  top: 8vh;
  transform: rotate(-8deg);
}

.kuromi-layer-b {
  width: min(28vw, 390px);
  right: 2vw;
  bottom: 8vh;
  transform: rotate(6deg);
  animation-duration: 20s;
}

.kuromi-layer-c {
  width: min(24vw, 340px);
  right: 32vw;
  top: 4vh;
  transform: rotate(3deg);
  animation-duration: 18s;
}

.page {
  width: min(1120px, 93vw);
  padding: 30px 0 54px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: relative;
  z-index: 2;
}

.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(640px 480px at 18% 9%, rgba(255, 116, 199, 0.3), transparent 68%),
    radial-gradient(660px 480px at 82% 14%, rgba(255, 162, 222, 0.3), transparent 65%),
    linear-gradient(145deg, #320a25, #5d1a48 48%, #21081a);
  z-index: 10;
}

.gate.is-hidden {
  display: none;
}

.gate-kuromi {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.gate-kuromi-layer {
  position: absolute;
  opacity: 0.22;
  mix-blend-mode: screen;
  filter: saturate(1.15);
  animation: kuromiDrift 18s ease-in-out infinite alternate;
}

.gate-kuromi-a {
  width: min(34vw, 470px);
  top: -4vh;
  left: -6vw;
  transform: rotate(-8deg);
}

.gate-kuromi-b {
  width: min(30vw, 420px);
  right: -2vw;
  bottom: 4vh;
  transform: rotate(8deg);
  animation-duration: 22s;
}

.gate-kuromi-c {
  width: min(24vw, 350px);
  left: 43vw;
  top: 6vh;
  transform: rotate(4deg);
  animation-duration: 20s;
}

.gate-card {
  width: min(980px, 94vw);
  padding: 20px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(62, 12, 45, 0.92), rgba(46, 13, 39, 0.88));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 24px 70px var(--shadow);
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(340px, 1fr);
  gap: 24px;
  align-items: stretch;
  position: relative;
  z-index: 2;
}

.gate-media {
  min-height: 440px;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 14px 30px rgba(0, 0, 0, 0.32);
}

.gate-visual {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gate-panel {
  display: grid;
  grid-template-rows: auto auto auto auto auto;
  align-content: center;
  gap: 14px;
  padding: 10px 10px 10px 2px;
}

.gate-toolbar {
  display: flex;
  justify-content: flex-end;
}

.gate-title {
  margin: 0;
  font-size: clamp(24px, 2.8vw, 30px);
}

.gate-sub {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
}

.gate-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.gate-input {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}

.gate-input:focus {
  outline: 2px solid rgba(255, 120, 216, 0.45);
  outline-offset: 1px;
}

.gate-error {
  margin: 0;
  font-size: 13px;
  color: var(--danger);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.gate-error.is-visible {
  opacity: 1;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
}

.hero-main {
  display: flex;
  align-items: center;
  gap: 18px;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hero-love-line {
  margin: 0;
  color: #ffd6ef;
  font-size: clamp(16px, 2vw, 22px);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.hero-flower {
  width: min(16vw, 160px);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 20px rgba(37, 6, 25, 0.36));
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 11px;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.04;
  font-weight: 700;
}

.sub {
  margin: 8px 0 0;
  max-width: 620px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.skip-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.skip-stack .control {
  width: 100%;
}

.skip-stack-stage {
  position: relative;
  left: auto;
  top: auto;
  transform: none;
  width: min(240px, 92%);
  margin: 14px auto 6px;
  z-index: 4;
}

.skip-stack-stage.is-hidden {
  display: none;
}

.valentine-question {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  width: min(440px, 88%);
  padding: 20px 18px;
  border-radius: 18px;
  border: 1px solid rgba(255, 156, 224, 0.6);
  background: linear-gradient(160deg, rgba(111, 26, 78, 0.94), rgba(55, 15, 41, 0.95));
  box-shadow: 0 22px 46px rgba(22, 5, 18, 0.46);
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.valentine-question.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.valentine-title {
  margin: 0;
  text-align: center;
  font-size: clamp(20px, 2.8vw, 30px);
  letter-spacing: 0.02em;
  color: #ffe8f8;
}

.valentine-actions {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.valentine-btn {
  text-transform: none;
  letter-spacing: 0.03em;
  font-size: 16px;
}

.valentine-btn-no {
  min-width: 104px;
  font-size: 14px;
  font-weight: 700;
  color: #fff4fa;
  border: 1px solid rgba(255, 130, 130, 0.75);
  background: linear-gradient(160deg, rgba(214, 59, 96, 0.86), rgba(149, 25, 63, 0.9));
  box-shadow: 0 10px 24px rgba(150, 26, 63, 0.35);
  height: 44px;
  padding: 0 14px;
  transform: scale(var(--no-scale, 1));
  transform-origin: center;
  transition: transform 0.22s ease;
}

.valentine-btn-no:hover,
.valentine-btn-no:focus {
  transform: scale(var(--no-scale, 1));
}

.yes-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  border: 0;
  background:
    radial-gradient(circle at 40% 30%, rgba(255, 187, 231, 0.45), transparent 60%),
    linear-gradient(145deg, rgba(143, 24, 80, 0.95), rgba(81, 17, 45, 0.95));
  color: #fff6fc;
  font-size: clamp(44px, 10vw, 120px);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  animation: yesPulse 1.4s ease-in-out infinite alternate;
}

.yes-fullscreen.is-visible {
  display: grid;
  place-items: center;
}

.firework-scene {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: none;
  place-items: center;
  background:
    linear-gradient(rgba(28, 5, 22, 0.38), rgba(28, 5, 22, 0.38)),
    url('../bg_fireworks/0175DE80-3B1E-4165-9FC5-97FA6C2008E9_1_105_c.jpeg') center / cover no-repeat;
}

.firework-scene.is-visible {
  display: grid;
  animation: fireworksFadeIn 0.5s ease forwards;
}

.firework-gif {
  width: min(84vw, 1100px);
  height: auto;
  object-fit: contain;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

@keyframes fireworksFadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

@keyframes yesPulse {
  0% {
    text-shadow: 0 0 18px rgba(255, 204, 239, 0.45);
    transform: scale(1);
  }
  100% {
    text-shadow: 0 0 34px rgba(255, 217, 245, 0.72);
    transform: scale(1.03);
  }
}

.valentine-btn.is-selected {
  border-color: rgba(255, 226, 245, 0.95);
  background: linear-gradient(160deg, rgba(255, 172, 223, 0.32), rgba(255, 101, 191, 0.2));
}

.language-switch {
  display: flex;
  align-items: center;
  gap: 10px;
}

.language-switch-gate .language-label {
  font-size: 10px;
}

.language-switch-gate .language-select {
  min-width: 160px;
  padding: 8px 38px 8px 14px;
}

.language-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.language-shell {
  position: relative;
}

.language-select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(255, 120, 216, 0.62);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.02)),
    linear-gradient(160deg, rgba(82, 20, 57, 0.96), rgba(59, 14, 46, 0.92));
  color: var(--text);
  min-width: 192px;
  padding: 10px 42px 10px 16px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 10px 24px rgba(255, 120, 216, 0.24);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.language-select:hover {
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 12px 26px rgba(255, 120, 216, 0.28);
}

.language-select:focus {
  outline: 2px solid rgba(255, 120, 216, 0.52);
  outline-offset: 1px;
}

.language-caret {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #ffd7f5;
  font-size: 14px;
  pointer-events: none;
  text-shadow: 0 0 14px rgba(255, 120, 216, 0.4);
}

.control {
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.05));
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.control:hover {
  transform: translateY(-1px);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.08));
}

.control.valentine-btn-no:hover,
.control.valentine-btn-no:focus {
  transform: scale(var(--no-scale, 1)) !important;
}

.status {
  padding: 11px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card-soft);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.25);
  color: var(--muted);
  font-size: 13px;
}

.stage {
  position: relative;
  padding: clamp(14px, 2vw, 24px);
  border-radius: 30px;
  border: 1px solid var(--line);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    linear-gradient(160deg, rgba(76, 16, 59, 0.8), rgba(41, 11, 34, 0.8));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.09),
    0 28px 70px var(--shadow);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(12px, 2vw, 22px);
}

.tile {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(70, 14, 52, 0.86);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: float 6s ease-in-out infinite;
}

.tile::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0), rgba(0, 0, 0, 0.22));
  pointer-events: none;
}

.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.tile.is-empty video {
  opacity: 0;
}

.tile.is-ending video {
  opacity: 0;
  transform: scale(0.98);
}

.start {
  position: relative;
  display: block;
  margin: 0 auto 10px;
  width: min(360px, 92%);
  border-radius: 999px;
  border: 1px solid rgba(255, 120, 216, 0.66);
  background:
    linear-gradient(180deg, rgba(255, 120, 216, 0.4), rgba(255, 95, 178, 0.26)),
    linear-gradient(160deg, rgba(92, 20, 64, 0.96), rgba(59, 14, 44, 0.95));
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-family: inherit;
  padding: 12px 20px;
  text-align: center;
  box-shadow: 0 12px 26px rgba(255, 120, 216, 0.36);
  cursor: pointer;
  z-index: 4;
}

.start.is-hidden {
  display: none;
}

.fireworks {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.fireworks.is-active {
  opacity: 1;
}

.end-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.98);
  opacity: 0;
  z-index: 2;
  padding: 22px 34px;
  border-radius: 20px;
  border: 1px solid rgba(255, 120, 216, 0.62);
  background: linear-gradient(160deg, rgba(97, 22, 71, 0.96), rgba(55, 13, 43, 0.96));
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.38);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.end-message.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.fireworks::before,
.fireworks::after {
  content: '';
  position: absolute;
  top: 34%;
  left: 52%;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: radial-gradient(circle, #ffe8fb 0%, transparent 70%);
  box-shadow:
    0 0 14px rgba(255, 255, 255, 0.62),
    44px -10px 0 -4px #ff78d8,
    -38px 10px 0 -4px #ff5ebb,
    20px 28px 0 -5px #ff9fe6,
    -22px 26px 0 -5px #ff88cf;
  animation: burst 1.2s ease-out forwards;
}

.fireworks::after {
  top: 64%;
  left: 35%;
  animation-delay: 0.2s;
}

@keyframes float {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes burst {
  0% {
    transform: translate(-50%, -50%) scale(0.2);
    opacity: 0;
  }
  28% {
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.65);
    opacity: 0;
  }
}

@keyframes kuromiDrift {
  0% {
    transform: translate3d(0, 0, 0) rotate(-2deg);
  }
  100% {
    transform: translate3d(0, -14px, 0) rotate(2deg);
  }
}

@media (max-width: 980px) {
  .gate-card {
    width: min(760px, 94vw);
    grid-template-columns: 1fr;
    padding: 18px;
    gap: 16px;
  }

  .gate-media {
    min-height: 300px;
  }

  .gate-panel {
    padding: 4px;
  }

  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-main {
    width: 100%;
    justify-content: space-between;
  }

  .hero-flower {
    width: min(30vw, 150px);
  }

  .controls {
    width: 100%;
    align-items: flex-start;
    flex-wrap: wrap;
    flex-direction: row;
    gap: 12px;
  }

  .language-switch {
    width: 100%;
    justify-content: space-between;
  }

  .language-shell {
    flex: 1;
    max-width: 320px;
  }

  .language-select {
    width: 100%;
  }

  .status {
    order: 10;
  }

  .skip-stack-stage {
    width: min(240px, 92%);
  }

  .valentine-question {
    width: min(500px, 92%);
  }
}

@media (max-width: 720px) {
  .page {
    width: min(1120px, 95vw);
    padding-top: 24px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .hero-main {
    align-items: flex-end;
    gap: 10px;
  }

  .hero-flower {
    width: min(38vw, 130px);
  }

  .skip-stack-stage {
    width: min(240px, 92%);
    margin: 12px auto 4px;
  }

  .valentine-question {
    position: static;
    transform: none;
    width: min(360px, 94%);
    margin: 12px auto 4px;
  }

  .valentine-question.is-visible {
    transform: none;
  }

  .gate-kuromi-layer {
    opacity: 0.15;
  }

  .gate-kuromi-a {
    width: 50vw;
    left: -14vw;
    top: 2vh;
  }

  .gate-kuromi-b {
    width: 46vw;
    right: -12vw;
    bottom: 8vh;
  }

  .gate-kuromi-c {
    width: 38vw;
    left: 34vw;
    top: -1vh;
  }

  .kuromi-layer {
    opacity: 0.14;
  }

  .kuromi-layer-a {
    width: 46vw;
    left: -10vw;
    top: 12vh;
  }

  .kuromi-layer-b {
    width: 44vw;
    right: -8vw;
    bottom: 12vh;
  }

  .kuromi-layer-c {
    width: 38vw;
    right: 30vw;
    top: 2vh;
  }

  .control {
    width: calc(50% - 6px);
    text-align: center;
  }

  .status {
    width: 100%;
    text-align: center;
  }

  .valentine-actions .control {
    width: 100%;
  }

  .start {
    width: min(360px, 92%);
  }

  .end-message {
    font-size: 18px;
    padding: 16px 20px;
    letter-spacing: 0.08em;
  }
}

@media (max-width: 420px) {
  .gate-card {
    padding: 14px;
  }

  .gate-media {
    min-height: 220px;
  }

  .gate-kuromi-c {
    display: none;
  }

  .control {
    width: 100%;
  }

  .gate-row {
    grid-template-columns: 1fr;
  }

  .gate-toolbar {
    justify-content: stretch;
  }

  .language-switch-gate {
    width: 100%;
    justify-content: space-between;
  }

  .language-switch-gate .language-shell {
    flex: 1;
    max-width: 200px;
  }

  .language-switch-gate .language-select {
    width: 100%;
  }
}
