/* BitBrew Café v2.0 — Ace Attorney Single-Turn Layout */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@300;400;700&display=swap');

:root {
  --bg: #1a1008;
  --fg: #F5E6C8;
  --orange: #F7931A;
  --amber: #FFB347;
  --dim: #A89070;
  --border: #3D2B1A;
  --surface: #241810;

  --pad-x: 24px;
  --pad-y: 16px;
  --space-xs: 8px;
  --space-sm: 16px;
  --space-md: 24px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.6;
  overflow: hidden;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

button, input {
  font-family: inherit;
}

img {
  display: block;
  max-width: 100%;
}

/* ──────────────────────────────────────────────────────────────── */
/* Game Canvas */
/* ──────────────────────────────────────────────────────────────── */

#game {
  width: 100%;
  max-width: calc(100dvh * (9 / 16));
  height: 100dvh;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

#game::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.08;
  background-image: url('../../assets/images/title.jpg');
  background-size: cover;
  background-position: center top;
}

#game::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0.12;
  background: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.45) 3px,
    transparent 4px
  );
}

@media (min-aspect-ratio: 9/16) {
  #game {
    max-width: 100vw;
    width: calc(100dvh * (9 / 16));
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

.screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.screen-dialogue,
.screen-alert {
  background-image: url('../../assets/images/game-bg.jpg');
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}

.screen-dialogue::before,
.screen-alert::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.screen-dialogue::after,
.screen-alert::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(to bottom, transparent 60%, rgba(0, 0, 0, 0.45) 100%);
  pointer-events: none;
}

.screen.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ──────────────────────────────────────────────────────────────── */
/* Title Screen */
/* ──────────────────────────────────────────────────────────────── */

.screen-title {
  padding: 0;
}

.title-graphic {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  z-index: 1;
}

.title-graphic img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.title-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 2;
  padding: var(--pad-x);
  background: rgba(26, 16, 8, 0.92);
}

.title-controls .btn-primary {
  margin-bottom: var(--space-sm);
  border: none;
  background: var(--orange);
  color: var(--bg);
}

.title-controls .reset-btn {
  border: none;
  background: transparent;
  color: var(--dim);
}

.title-controls .reset-btn:hover,
.title-controls .reset-btn:focus {
  color: var(--orange);
}

.version {
  color: var(--dim);
  font-size: 0.85rem;
  text-align: center;
  margin: 0;
}

/* ──────────────────────────────────────────────────────────────── */
/* Character Select */
/* ──────────────────────────────────────────────────────────────── */

.screen-char-select {
  padding: var(--pad-y) var(--pad-x);
  overflow-y: auto;
}

.screen-char-select::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.5;
  background-image: url('../../assets/images/title.jpg');
  background-size: cover;
  background-position: center top;
}

.screen-char-select .tag {
  text-align: center;
  margin-bottom: var(--space-xs);
}

.screen-char-select h2 {
  text-align: center;
  margin: 0 0 var(--space-md);
}

.char-select-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
  margin-top: 0;
}

.char-card {
  border: 4px solid var(--fg);
  background: var(--bg);
  padding: var(--space-sm);
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
}

.char-card:hover,
.char-card:focus {
  border-color: var(--orange);
  background: var(--surface);
}

.char-card img.portrait {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: top;
}

.fact-panel {
  border: 2px solid var(--fg);
  background: rgba(26, 16, 8, 0.94);
  padding: var(--space-md);
  margin-top: var(--space-md);
  text-align: left;
}

.fact-panel .fact-label {
  color: var(--orange);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-xs);
  display: block;
}

.fact-panel p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
}

.char-card .label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ──────────────────────────────────────────────────────────────── */
/* Dialogue Screen (single turn) */
/* ──────────────────────────────────────────────────────────────── */

.dialogue-card {
  padding: 0;
}

.scene-header {
  position: absolute;
  top: var(--pad-y);
  left: var(--pad-x);
  z-index: 10;
}

.scene-id {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--dim);
  background: rgba(26, 16, 8, 0.85);
  padding: 4px 8px;
}

.scene-menu {
  position: absolute;
  top: var(--pad-y);
  right: var(--pad-x);
  z-index: 10;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  background: rgba(26, 16, 8, 0.85);
  border: 1px solid var(--border);
  padding: 6px 10px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.scene-menu:hover,
.scene-menu:focus {
  color: var(--orange);
  border-color: var(--orange);
}

.alert-banner {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 5;
  border-bottom: 2px solid var(--orange);
  background: var(--surface);
  padding: var(--pad-y) var(--pad-x);
}

.alert-banner p {
  margin: 0;
  color: var(--orange);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: center;
}

.graphic-zone {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  background: var(--surface);
  border-bottom: 4px solid var(--fg);
  position: relative;
  z-index: 1;
  overflow: hidden;
}

.graphic-zone img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.placeholder-character {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--space-sm);
}

.placeholder-emoji {
  font-size: clamp(4rem, 25vw, 7rem);
  line-height: 1;
}

.placeholder-name {
  font-size: clamp(1.2rem, 6vw, 1.8rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

.dialogue-zone {
  flex: 0 0 38%;
  width: 100%;
  min-height: 0;
  padding: var(--pad-x);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  background: rgba(26, 16, 8, 0.82);
  position: relative;
  z-index: 1;
}

.dialogue-zone.left {
  align-items: flex-start;
  text-align: left;
}

.dialogue-zone.right {
  align-items: flex-end;
  text-align: right;
}

.dialogue-zone.center {
  align-items: center;
  text-align: center;
}

.dialogue-zone.overheard {
  align-items: center;
  text-align: center;
  justify-content: flex-start;
  padding-top: var(--space-md);
}

.dialogue-zone.overheard .name-plate {
  color: var(--dim);
  font-size: 0.85rem;
  margin-bottom: var(--space-xs);
}

.bubble.overheard {
  width: 92%;
  border: 2px dashed var(--dim);
  background: rgba(36, 24, 16, 0.85);
  padding: var(--space-sm);
  font-style: italic;
  color: var(--fg);
  min-height: unset;
}

.name-plate {
  font-size: clamp(1rem, 3.5vw, 1.2rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg);
  margin-bottom: var(--space-xs);
  padding: 6px 0;
  flex-shrink: 0;
}

.name-plate.sats {
  color: var(--orange);
}

.bubble {
  width: 100%;
  border: 4px solid var(--fg);
  background: var(--surface);
  padding: var(--space-sm);
  flex: 1 1 auto;
  overflow-y: auto;
}

.bubble p {
  margin: 0 0 var(--space-xs);
}

.bubble p:last-child {
  margin-bottom: 0;
}

.bubble .emphatic {
  color: var(--orange);
  font-weight: 700;
}

.bubble .shock-pop {
  display: inline-block;
  animation: shock 0.3s ease-out;
}

@keyframes shock {
  0% { transform: translateY(-4px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

.continue-prompt {
  margin-top: var(--space-sm);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  animation: pulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ──────────────────────────────────────────────────────────────── */
/* Sats Corner Popup */
/* ──────────────────────────────────────────────────────────────── */

.sats-corner {
  position: absolute;
  top: 64px;
  right: var(--pad-x);
  z-index: 20;
  display: flex;
  align-items: flex-start;
  gap: var(--space-xs);
  max-width: 66%;
  pointer-events: none;
}

.sats-avatar {
  width: 48px;
  height: 48px;
  border: 2px solid var(--fg);
  object-fit: cover;
  background: var(--bg);
  flex-shrink: 0;
}

.sats-balloon {
  border: 2px solid var(--fg);
  background: rgba(26, 16, 8, 0.96);
  padding: var(--space-xs) var(--space-sm);
  text-align: left;
}

.sats-label {
  color: var(--orange);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.sats-bubble {
  font-size: 0.9rem;
  line-height: 1.4;
}

.sats-continue {
  margin-top: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  animation: pulse 1.2s ease-in-out infinite;
}

/* ──────────────────────────────────────────────────────────────── */
/* Choices */
/* ──────────────────────────────────────────────────────────────── */

.choice-menu {
  width: 100%;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-y: auto;
}

.choice-prompt {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: var(--space-sm);
}

.choice {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 14px 8px;
  border: none;
  background: transparent;
  color: var(--fg);
  font-size: 1rem;
  line-height: 1.4;
  text-align: center;
  cursor: pointer;
  transition: color 0.2s, transform 0.05s;
}

.choice::before {
  content: '→ ';
  color: var(--orange);
}

.choice:hover,
.choice:focus {
  color: var(--orange);
}

.choice:active {
  transform: scale(0.98);
}

.choice-number {
  color: var(--orange);
  font-weight: 700;
}

/* ──────────────────────────────────────────────────────────────── */
/* Buttons */
/* ──────────────────────────────────────────────────────────────── */

.btn-primary {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 4px solid var(--fg);
  background: var(--bg);
  color: var(--fg);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background-color 0.2s, transform 0.05s;
  margin-bottom: var(--space-sm);
}

.btn-primary:hover,
.btn-primary:focus {
  border-color: var(--orange);
  color: var(--orange);
  background: var(--surface);
}

.btn-primary:active {
  transform: scale(0.98);
}

.reset-btn {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--dim);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  margin-top: var(--space-sm);
}

.reset-btn:hover,
.reset-btn:focus {
  color: var(--orange);
  border-color: var(--orange);
}

/* ──────────────────────────────────────────────────────────────── */
/* Gate & End */
/* ──────────────────────────────────────────────────────────────── */

.screen-gate,
.screen-end {
  padding: var(--pad-y) var(--pad-x);
  text-align: center;
  position: relative;
}

.screen-gate-image .gate-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: 0;
  opacity: 0.55;
}

.gate-body {
  position: relative;
  z-index: 1;
  margin-top: auto;
  margin-bottom: auto;
  background: rgba(26, 16, 8, 0.82);
  padding: var(--space-md);
}

.gate-line {
  margin-bottom: var(--space-sm);
}

.gate-hint {
  color: var(--dim);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.gate-flag {
  color: var(--dim);
}

.end-list {
  text-align: left;
  display: inline-block;
  margin: var(--space-md) 0;
}

.end-list p {
  margin: 0.25rem 0;
}

.list-item::before {
  content: '→ ';
  color: var(--orange);
}

/* ──────────────────────────────────────────────────────────────── */
/* Seed Phrase Screen */
/* ──────────────────────────────────────────────────────────────── */

.screen-seed {
  padding: var(--pad-y) var(--pad-x);
  overflow-y: auto;
}

.seed-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: var(--space-md);
}

.seed-title {
  margin: 0 0 var(--space-xs);
}

.seed-subtitle {
  color: var(--orange);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 var(--space-md);
}

.seed-words {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-xs);
  width: 100%;
  margin-bottom: var(--space-md);
}

.seed-word {
  border: 2px solid var(--fg);
  background: var(--surface);
  padding: 8px 4px;
  font-weight: 700;
  font-size: 0.95rem;
  text-transform: uppercase;
}

.seed-word em {
  color: var(--dim);
  font-style: normal;
  margin-right: 4px;
  font-weight: 400;
}

.seed-warnings {
  text-align: left;
  width: 100%;
  margin: 0 0 var(--space-md);
  padding-left: var(--space-sm);
}

.seed-warnings li {
  margin-bottom: var(--space-xs);
  line-height: 1.4;
}

.seed-cta {
  margin-bottom: 0;
}

.hidden {
  display: none !important;
}

.type-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--orange);
  margin-left: 2px;
  animation: blink 0.8s step-end infinite;
  vertical-align: text-bottom;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
