:root {
  --navy: #17235e;
  --navy-deep: #0a1740;
  --blue-light: #6f8ee8;
  --bg: #ece6d8;
  --bg-alt: #e2dac8;
  --green: #5cae4a;
  --green-dark: #1f3b17;
  --green-shadow: #2f6a24;
  --green-shine: #8fd67e;
  --red: #e2555f;
  --panel: #d8d2c2;
  --panel-shadow: #a89f89;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  background: var(--bg);
  font-family: 'VT323', monospace;
  color: var(--navy);
}

button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
}

@keyframes blinkcursor { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes toastin { from { transform: translate(-50%, 10px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes loadfill { from { width: 8%; } to { width: 92%; } }
@keyframes folderwiggle { 0%, 49% { transform: rotate(-7deg); } 50%, 100% { transform: rotate(-1deg); } }

.blink { animation: blinkcursor 1s steps(1) infinite; }

.page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px 40px;
}

.frame {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.frame.home-gap { gap: 70px; }

.window-wrap {
  position: relative;
  width: 100%;
}

.mystery-cube {
  position: absolute;
  right: -28px;
  bottom: calc(8% - 100px);
  width: 34%;
  max-width: 140px;
  z-index: 2;
  filter: drop-shadow(4px 6px 0 rgba(23, 35, 94, .4));
  animation: folderwiggle .6s steps(1) infinite;
  transform-origin: 50% 90%;
  pointer-events: none;
}
.mystery-cube[hidden] { display: none; }
.mystery-cube img { width: 100%; display: block; }

.loading-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 340px;
}
.loading-wrap[hidden] { display: none; }

.loading-bar {
  width: 70%;
  height: 16px;
  border: 3px solid var(--navy);
  background: #fff;
  padding: 2px;
}
.loading-fill {
  height: 100%;
  background: repeating-linear-gradient(90deg, var(--navy) 0 6px, #3a56b0 6px 12px);
  animation: loadfill 1.6s ease-out both;
}
.loading-text {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: var(--navy);
  letter-spacing: 2px;
}

.window {
  width: 100%;
  height: min(640px, 68vh);
  min-height: 440px;
  transition: height .15s ease;
  border: 5px solid var(--navy);
  box-shadow: inset -4px -4px 0 var(--navy-deep), inset 4px 4px 0 var(--blue-light);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  position: relative;
}

.titlebar {
  height: 34px;
  background: var(--navy);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  flex-shrink: 0;
}
.tbtitle {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: #fff;
  letter-spacing: 1px;
  flex: 1;
}
.tbcontrols { display: flex; gap: 4px; }
.tbtn {
  width: 16px;
  height: 16px;
  background: #c7cfe8;
  border: 2px solid var(--navy-deep);
  font-size: 8px;
  line-height: 12px;
  text-align: center;
  color: var(--navy);
  font-weight: 700;
}
.tbtn-back {
  cursor: pointer;
  font-size: 12px;
  line-height: 12px;
}
.tbtn-back[hidden] { display: none; }
.tbtn-close {
  background: var(--red);
  color: #fff;
  cursor: pointer;
}
.tbtn-close.small {
  width: 13px;
  height: 13px;
  font-size: 7px;
  line-height: 9px;
}

.content { position: relative; flex: 1; overflow: hidden; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; }
.screen[hidden] { display: none; }

/* HOME */
.scene {
  position: relative;
  flex: 1;
  overflow: hidden;
}
.scene-photo {
  background-image: url('assets/home-scene.jpeg');
  background-size: cover;
  background-position: center;
}
.scene-logo {
  position: absolute;
  left: 50%;
  top: calc(11% + 110px);
  transform: translate(-50%, -50%);
  text-align: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 45px;
  letter-spacing: -1px;
  background: linear-gradient(180deg, #ffe45c 0%, #ffb020 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 2px var(--navy);
  filter: drop-shadow(3px 3px 0 var(--navy)) drop-shadow(5px 5px 0 rgba(23, 35, 94, .5));
  white-space: nowrap;
}

.start-btn {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  cursor: pointer; padding: 16px 30px;
  background: var(--green); border: 4px solid var(--green-dark);
  box-shadow: inset -4px -4px 0 var(--green-shadow), inset 4px 4px 0 var(--green-shine);
  font-family: 'Press Start 2P', monospace; font-size: 20px; color: #fff; letter-spacing: 2px;
  transition: transform .1s ease, filter .1s ease;
}
.start-btn:hover { filter: brightness(1.06); }
.start-btn:active {
  transform: translate(-50%, -50%) translateY(2px);
  box-shadow: inset -2px -2px 0 var(--green-shadow), inset 2px 2px 0 var(--green-shine);
}

/* SELECT */
.select-scroll {
  flex: 1; overflow: auto;
  background-image: url('assets/select-bg.jpeg');
  background-size: cover;
  background-position: center;
  padding: 22px 18px 24px;
  display: flex; flex-direction: column; gap: 20px; align-items: center;
}
.select-heading {
  font-family: 'Press Start 2P', monospace; font-size: 11px; color: var(--navy);
  text-align: center; letter-spacing: 1px;
}

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; width: 100%; }

.tile {
  position: relative;
  background: #fff;
  border: 3px solid var(--navy);
  box-shadow: 3px 3px 0 rgba(23, 35, 94, .25);
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  transform: scale(1);
  transition: transform .12s ease, box-shadow .12s ease;
}
.tile.active {
  transform: scale(1.05);
  box-shadow: 0 0 0 3px #ffd23f, 4px 4px 0 rgba(23, 35, 94, .3);
}

.tile-titlebar {
  height: 20px;
  display: flex;
  align-items: center;
  padding: 0 6px;
  border-bottom: 2px solid var(--navy);
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #fff;
  letter-spacing: 0.5px;
}
.tile-titlebar-friendship { background: #f5b400; }
.tile-titlebar-love { background: #d1477a; }
.tile-titlebar-mystery { background: #e8720c; }
.tile-titlebar-ice { background: #2f8fb0; }

.tile-body {
  padding: 8px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.icon-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
}

.tile-icon {
  width: 80px;
  height: 80px;
  object-fit: contain;
  image-rendering: pixelated;
  display: block;
}

.tile-label {
  font-family: 'Press Start 2P', monospace; font-size: 11px; color: var(--navy); text-align: center;
}
.tile[data-topic="Friendship"].active .tile-label { color: #f5b400; }
.tile[data-topic="Love/Date"].active .tile-label { color: #d1477a; }
.tile[data-topic="Mystery"].active .tile-label { color: #e8720c; }
.tile[data-topic="Ice Breakers"].active .tile-label { color: #2f8fb0; }

/* confirm card */
.confirm-card {
  width: 100%; border: 3px solid var(--navy); background: #fff;
  box-shadow: 4px 4px 0 rgba(23, 35, 94, .25); flex-shrink: 0;
}
.confirm-card[hidden] { display: none; }
.confirm-titlebar {
  height: 22px; background: var(--navy); display: flex; align-items: center;
  justify-content: space-between; padding: 0 6px;
  font-family: 'Press Start 2P', monospace; font-size: 8px; color: #fff;
}
.confirm-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.confirm-text {
  font-family: 'Press Start 2P', monospace; font-size: 13px; color: var(--navy);
  text-align: center; line-height: 1.8;
}
.confirm-actions { display: flex; gap: 10px; width: 100%; }

.btn {
  flex: 1; text-align: center; padding: 10px 4px;
  font-family: 'Press Start 2P', monospace; font-size: 9px; cursor: pointer;
}
.btn-secondary { background: var(--panel); border: 3px solid var(--navy); box-shadow: inset -3px -3px 0 var(--panel-shadow); color: var(--navy); }
.btn-primary { background: var(--green); border: 3px solid var(--green-dark); box-shadow: inset -3px -3px 0 var(--green-shadow); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn-wide { flex: none; width: 75%; padding: 12px 4px; font-size: 10px; }

/* PLAY */
@keyframes tetrisFall {
  0% { transform: translateY(-160px); opacity: 0; }
  60% { transform: translateY(6px); opacity: 1; }
  80% { transform: translateY(-3px); }
  100% { transform: translateY(0); opacity: 1; }
}

.play-scroll {
  flex: 1; overflow: auto;
  background: repeating-linear-gradient(45deg, var(--bg) 0 8px, var(--bg-alt) 8px 16px);
  background-size: cover;
  background-position: center;
  padding: 24px 18px; display: flex; flex-direction: column; gap: 20px; align-items: center;
  justify-content: center;
}
.play-scroll.play-bg-friendship { background-image: url('assets/friendship-bg.jpeg'); }
.play-scroll.play-bg-love { background-image: url('assets/love-bg.jpeg'); }
.play-scroll.play-bg-mystery { background-image: url('assets/mystery-bg.jpeg'); }
.play-scroll.play-bg-ice { background-image: url('assets/icebreaker-bg.jpeg'); }

.play-topic {
  font-family: 'Press Start 2P', monospace; font-size: 15px;
  letter-spacing: 1px; text-align: center;
}
.play-topic.love-shift { margin-top: -30px; }
.question-card {
  width: 75%; min-height: 128px; border: 4px solid var(--navy); background: #fff;
  box-shadow: 5px 5px 0 rgba(23, 35, 94, .3);
  padding: 11px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center; overflow: hidden; flex-shrink: 0;
}
.question-mark {
  font-family: 'Press Start 2P', monospace; font-size: 15px; margin-top: 5px;
}
.question-words {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 5px 6px; margin: 6px 0;
}
.question-words span {
  font-family: 'Press Start 2P', monospace; font-size: 10px; color: var(--navy);
  display: inline-block; animation: tetrisFall .5s steps(5) both;
}

.life-bar-outer {
  display: flex; flex-direction: column; align-items: center;
  width: 100%;
}
.life-bar-outer[hidden] { display: none; }

.life-bar-wrap {
  position: relative; width: 100%;
  display: flex; align-items: center; justify-content: center;
}
.life-bar {
  width: 78%; height: 16px; border: 3px solid var(--navy); background: #fff;
  display: flex; padding: 2px; gap: 2px;
}
.life-bar-seg { flex: 1; height: 100%; background: transparent; transition: background .15s ease; }
.life-bar-icon {
  position: absolute; left: calc(14.9% - 40px); top: 50%; transform: translateY(-50%);
  width: 40px; height: 38px; z-index: 2;
}
.life-bar-icon img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.life-bar-icon.icon-friendship { left: calc(14.9% - 52px); width: 52px; height: 52px; }
.life-bar-icon.icon-ice { left: calc(14.9% - 50px); width: 50px; height: 50px; }
.life-bar-icon.icon-mystery { left: calc(14.9% - 36px); width: 36px; height: 36px; top: 68%; }

.life-bar-label {
  text-align: center; font-family: 'Press Start 2P', monospace; font-size: 11px;
  color: var(--navy); letter-spacing: 2px; margin-top: 8px;
}
.life-bar-label.narrow { font-size: 10px; margin-left: 7px; }

.toast {
  position: fixed; left: 50%; top: 0; transform: translateX(-50%);
  animation: toastin .25s ease-out;
  background: var(--navy); color: #fff; font-family: 'Press Start 2P', monospace;
  font-size: 9px; padding: 12px 16px; border: 3px solid var(--navy-deep);
  box-shadow: 0 4px 0 rgba(0, 0, 0, .2); white-space: nowrap; z-index: 50; text-align: center;
}
.toast[hidden] { display: none; }

.window.window-tall { height: min(618px, 80vh); }

@media (max-width: 420px) {
  .page { padding: 20px 12px 28px; }
  .frame { gap: 14px; }
  .window { height: min(620px, 72vh); }
  .window.window-tall { height: min(560px, 80vh); }
  .window-wrap { width: calc(100% - 40px); }
  .life-bar-outer { width: calc(100% - 40px); }
  .window.home-short { height: calc(min(620px, 72vh) - 100px); }

  .tile-titlebar { height: 16px; padding: 0 5px; font-size: 6px; }
  .tile-body { padding: 8px; gap: 12px; }
  .tile-icon { width: 64px; height: 64px; }
  .tile-label { font-size: 8px; white-space: nowrap; }

  .confirm-text { font-size: 10px; line-height: 1.5; }
}
