/* ==========================================================================
   Oma Ira & Wanja: Der rote Faden — Portrait 9:16 Mobile-First Styles
   ========================================================================== */

:root {
  --bg-shell: #2c2420;
  --paper: #fbf4e8;
  --paper-warm: #f3e4cd;
  --ink: #382a24;
  --ink-soft: #6c574d;
  --yarn: #c9322c;
  --yarn-dark: #941f1b;
  --yarn-glow: rgba(201, 50, 44, 0.25);
  --gold: #e3a73b;
  --sage: #5c8a66;
  --sky: #5584a8;
  --card: rgba(255, 250, 242, 0.94);
  --shadow: 0 8px 24px rgba(48, 32, 22, 0.16);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font-main: "Avenir Next", "Nunito", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: "Georgia", "Palatino Linotype", "Book Antiqua", serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 30%, #43352d 0%, #231b17 100%);
  font-family: var(--font-main);
  color: var(--ink);
}

#app-shell {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

/* Portrait 9:16 stage that fills mobile screens and centers cleanly on desktop */
#game-viewport {
  position: relative;
  width: min(100vw, calc(100vh * 9 / 16));
  height: min(100vh, calc(100vw * 16 / 9));
  max-width: 540px;
  max-height: 960px;
  background: var(--paper);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  border-radius: 0;
}

@media (min-width: 600px) {
  #game-viewport {
    border-radius: 24px;
    border: 3px solid rgba(255, 240, 220, 0.18);
  }
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#ui-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

#ui-layer .interactive {
  pointer-events: auto;
}

#modal-layer {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(34, 24, 19, 0.62);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#modal-layer.hidden {
  display: none;
}

/* ---------- Buttons (Big touch targets, no hover dependence) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.15);
}

.btn:active {
  transform: translateY(2px) scale(0.98);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
}

.btn-primary {
  background: linear-gradient(180deg, #dc433c 0%, var(--yarn) 100%);
  color: #fff;
  box-shadow: 0 5px 0 var(--yarn-dark);
}

.btn-primary:active {
  box-shadow: 0 2px 0 var(--yarn-dark);
}

.btn-secondary {
  background: var(--card);
  color: var(--ink);
  border: 2px solid #decbb3;
  box-shadow: 0 4px 0 #d5bea0;
}

.btn-secondary:active {
  box-shadow: 0 2px 0 #d5bea0;
}

.btn-sage {
  background: linear-gradient(180deg, #6da178 0%, var(--sage) 100%);
  color: #fff;
  box-shadow: 0 5px 0 #3f6347;
}

.btn-icon {
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border-radius: 50%;
  font-size: 22px;
  background: var(--card);
  color: var(--ink);
  border: 2px solid #decbb3;
  box-shadow: 0 4px 10px rgba(48, 32, 22, 0.16);
}

.btn-icon:active {
  transform: scale(0.94);
}

/* ---------- Cards & Modals ---------- */
.card {
  background: var(--card);
  border: 2px solid #e6d4bc;
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 380px;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--ink);
  text-align: center;
}

.card-subtitle {
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink-soft);
  margin: 0 0 18px;
  text-align: center;
}

/* ---------- Main Menu ---------- */
.menu-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px 22px 30px;
}

.menu-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lang-pill {
  display: inline-flex;
  background: var(--card);
  border: 2px solid #decbb3;
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
  box-shadow: 0 4px 10px rgba(48, 32, 22, 0.12);
}

.lang-pill button {
  border: none;
  background: transparent;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
}

.lang-pill button.active {
  background: var(--yarn);
  color: #fff;
}

.menu-hero {
  text-align: center;
  margin-top: 8px;
}

.menu-badge {
  display: inline-block;
  background: rgba(201, 50, 44, 0.12);
  color: var(--yarn-dark);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.menu-title {
  font-family: var(--font-serif);
  font-size: 32px;
  line-height: 1.15;
  margin: 0 0 8px;
  color: var(--ink);
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.8);
}

.menu-subtitle {
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink-soft);
  margin: 0 auto;
  max-width: 300px;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.menu-progress-note {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}

/* ---------- Top HUD (Map & Gameplay) ---------- */
.top-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 8px;
}

.hud-pill {
  background: var(--card);
  border: 2px solid #e2ceb5;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  box-shadow: 0 4px 10px rgba(48, 32, 22, 0.12);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hud-title {
  flex: 1;
  text-align: center;
  background: var(--card);
  border: 2px solid #e2ceb5;
  border-radius: 16px;
  padding: 8px 12px;
  font-weight: 800;
  font-size: 15px;
  color: var(--ink);
  box-shadow: 0 4px 10px rgba(48, 32, 22, 0.12);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Map Footer ---------- */
.map-footer {
  margin-top: auto;
  padding: 10px 16px 16px;
  display: flex;
  justify-content: center;
}

.map-hint-chip {
  background: rgba(255, 250, 242, 0.9);
  border: 1.5px solid #e2ceb5;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  box-shadow: 0 4px 12px rgba(48, 32, 22, 0.12);
}

/* ---------- Who Plays Banner ---------- */
.who-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 20px 28px;
}

.who-card {
  margin: auto 0;
  background: var(--card);
  border: 3px solid #e4cfb4;
  border-radius: 28px;
  padding: 24px 20px;
  text-align: center;
  box-shadow: var(--shadow);
}

.who-kicker {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--yarn);
  margin-bottom: 6px;
}

.who-level-name {
  font-family: var(--font-serif);
  font-size: 25px;
  margin: 0 0 14px;
  color: var(--ink);
}

.who-portraits {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 10px 0 14px;
}

.portrait-badge {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  border: 4px solid var(--yarn);
  background: #f5e5cf;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 18px rgba(48, 32, 22, 0.18);
}

.portrait-badge.vanya {
  border-color: var(--sky);
  background: #dcebf5;
}

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

.who-player-label {
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  margin: 0 0 6px;
}

.who-story {
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink-soft);
  margin: 0 0 18px;
}

/* ---------- Hidden Object HUD ---------- */
.ho-bottom-panel {
  margin-top: auto;
  background: linear-gradient(180deg, rgba(251, 244, 232, 0.96) 0%, #f3e4cd 100%);
  border-top: 3px solid #dec6a8;
  padding: 10px 12px 14px;
  box-shadow: 0 -8px 24px rgba(48, 32, 22, 0.16);
}

.ho-hints-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.ho-counter {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
}

.ho-hint-buttons {
  display: flex;
  gap: 6px;
}

.hint-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 5px 9px;
  border-radius: 999px;
  border: 2px solid #d9b98b;
  background: #fff9ef;
  color: var(--ink);
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}

.hint-btn:active {
  transform: scale(0.95);
}

.hint-btn.used {
  opacity: 0.42;
  background: #e9dfd1;
  border-color: #cbbba6;
  pointer-events: none;
}

.ho-items-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  max-height: 184px;
  overflow-y: auto;
  padding-right: 2px;
  -webkit-overflow-scrolling: touch;
}

.ho-item-chip {
  background: #fffdf8;
  border: 1.5px solid #e2ceb5;
  border-radius: 10px;
  padding: 5px 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  line-height: 1.15;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ho-item-chip.found {
  background: #e5f1e7;
  border-color: #9dc2a4;
  color: #4c7454;
  text-decoration: line-through;
  opacity: 0.78;
}

.ho-item-chip.highlighted {
  background: #fff0b8;
  border-color: #d99116;
  color: #6b3f00;
  animation: chipPulse 0.75s ease-in-out infinite alternate;
}

.ho-item-chip.just-found {
  animation: chipPop 0.45s ease;
}

@keyframes chipPulse {
  from { transform: scale(1); box-shadow: 0 0 0 0 rgba(227, 167, 59, 0.5); }
  to { transform: scale(1.05); box-shadow: 0 0 0 6px rgba(227, 167, 59, 0); }
}

@keyframes chipPop {
  0% { transform: scale(1); }
  45% { transform: scale(1.14); background: #d5f0da; }
  100% { transform: scale(1); }
}

/* ---------- Settings Modal ---------- */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #eadbc6;
}

.setting-row:last-of-type {
  border-bottom: none;
}

.setting-label {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.toggle-btn {
  min-width: 72px;
  min-height: 40px;
  border-radius: 999px;
  border: none;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  color: #fff;
  background: var(--sage);
}

.toggle-btn.off {
  background: #a99b8e;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.toast {
  position: absolute;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(56, 42, 36, 0.92);
  color: #fffaf2;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  z-index: 25;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  animation: toastIn 0.2s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
