/* ======================================
   GLOBAL PIXEL STYLE + BASE COLORS
====================================== */
@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap");

:root {
  --ink: #244f4b;
  --muted: #6e8491;
  --pill: #ffffff;
  --soft: rgba(255, 255, 255, 0.84);
  --line: #dbeaf1;
  --btn1: #78c9be;
  --btn2: #6bb7c8;
  --accent: #f4b75f;
  --rose: #ef8ea5;
  --violet: #9e94d9;
  --ring: #cfeef0;
  --shadow: 0 12px 28px rgba(60, 120, 140, 0.14);
  --radius: 12px;
  --error-bg: #ffe8e8;
  --error-text: #b93636;
  --panel-bg: rgba(31, 52, 72, 0.86);
  --panel-item: rgba(255, 255, 255, 0.12);
  --panel-line: rgba(173, 213, 232, 0.36);
  --sky-a: #cfeeff;
  --sky-b: #f7fdff;
}

body[data-theme="dusk"] {
  --ink: #3f4155;
  --muted: #7d7087;
  --btn1: #f1b47c;
  --btn2: #df8f9d;
  --accent: #f7ca67;
  --sky-a: #ffd6a2;
  --sky-b: #f5e9ff;
}

body[data-theme="night"] {
  --ink: #e9f4f7;
  --muted: #b4c4d1;
  --pill: #1f3448;
  --soft: rgba(31, 52, 72, 0.86);
  --line: #426175;
  --btn1: #7cc7d8;
  --btn2: #8f96dd;
  --accent: #f2d06b;
  --sky-a: #142339;
  --sky-b: #273a5a;
}

body[data-theme="meadow"] {
  --ink: #284a35;
  --muted: #6f846a;
  --btn1: #8dcf8d;
  --btn2: #6bb7c8;
  --accent: #f4be61;
  --sky-a: #c9f0d2;
  --sky-b: #f8ffe9;
}

body[data-theme="winter"] {
  --ink: #294b66;
  --muted: #718b9e;
  --btn1: #8dcce6;
  --btn2: #a5afd9;
  --accent: #f0c46f;
  --sky-a: #d8f4ff;
  --sky-b: #ffffff;
}

body[data-theme="aurora"] {
  --ink: #e9fff8;
  --muted: #bed5df;
  --pill: #1c3450;
  --soft: rgba(28, 52, 80, 0.86);
  --line: #4e788c;
  --btn1: #78d5bd;
  --btn2: #7d90da;
  --accent: #f7dc72;
  --sky-a: #12233f;
  --sky-b: #25456b;
}

body[data-theme="candy"] {
  --ink: #4f4966;
  --muted: #816f91;
  --btn1: #86d7e8;
  --btn2: #f2a5c2;
  --accent: #f6c661;
  --sky-a: #ffd3ea;
  --sky-b: #d7f7ff;
}

body[data-theme="storm"] {
  --ink: #eef7fb;
  --muted: #c1cfd8;
  --pill: #2b394e;
  --soft: rgba(35, 48, 68, 0.86);
  --line: #657b8e;
  --btn1: #8ec3d3;
  --btn2: #8794b6;
  --accent: #f7df7d;
  --sky-a: #243044;
  --sky-b: #5d7184;
}

body[data-theme="space"] {
  --ink: #f0f4ff;
  --muted: #bbc1dd;
  --pill: #161f3d;
  --soft: rgba(22, 31, 61, 0.88);
  --line: #4c5d92;
  --btn1: #78c9be;
  --btn2: #8f79d9;
  --accent: #fff4b8;
  --sky-a: #0b1430;
  --sky-b: #241d4b;
}

body[data-theme="sunrise"] {
  --ink: #4c4f4d;
  --muted: #7e7770;
  --btn1: #83cfca;
  --btn2: #f4a186;
  --accent: #f7ca67;
  --sky-a: #ffbc8b;
  --sky-b: #fff1c4;
}

body.birthday-mode {
  --btn1: #f7cf65;
  --btn2: #ef8ea5;
  --accent: #78c9be;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  min-height: 100dvh;
  overflow: hidden;
  font-family: "Press Start 2P", monospace;
  -webkit-font-smoothing: none;
  background: linear-gradient(180deg, var(--sky-a), var(--sky-b));
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.22);
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

#screens {
  width: 100%;
  min-height: 100dvh;
}

.screen {
  width: 100%;
  min-height: 100dvh;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.screen.is-leaving {
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}

.screen.is-entering {
  opacity: 0;
  transform: translateY(-12px);
}

.screen.is-entering.is-active {
  opacity: 1;
  transform: translateY(0);
}

.hidden {
  display: none !important;
}

/* ======================================
   WELCOME SCREEN
====================================== */
#welcome {
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
}

.welcome-content {
  width: min(100%, 720px);
}

#welcome .title {
  margin: 0 0 18px;
  color: #2c7f77;
  font-size: 28px;
  letter-spacing: 0;
  line-height: 1.35;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.03);
}

body[data-theme="night"] #welcome .title {
  color: #d7f9ff;
}

#welcome .hint {
  max-width: 620px;
  margin: 0 auto 22px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.controls {
  display: flex;
  align-items: end;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  margin: 0 auto 12px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
  text-align: left;
}

input,
select {
  min-height: 48px;
  padding: 13px 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  background: var(--pill);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 11px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#bdayInput {
  width: 260px;
}

input:focus,
select:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 4px rgba(207, 238, 240, 0.55);
}

#startBtn,
.clear-btn,
.hud-btn,
.secondary-btn,
.segment-btn,
.mood-btn,
.swatch-btn {
  min-height: 44px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: filter 0.2s, transform 0.06s, border-color 0.15s;
}

#startBtn {
  min-height: 48px;
  padding: 13px 22px;
  background: linear-gradient(180deg, var(--btn1), var(--btn2));
  color: #073a3a;
  box-shadow: 0 10px 24px rgba(80, 170, 170, 0.25);
  font-size: 12px;
}

.clear-btn,
.secondary-btn,
.segment-btn,
.mood-btn {
  border: 2px solid var(--line);
  background: var(--soft);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 10px;
}

.secondary-btn {
  padding: 12px 14px;
}

#startBtn:hover,
.clear-btn:hover,
.hud-btn:hover,
.secondary-btn:hover,
.segment-btn:hover,
.mood-btn:hover,
.swatch-btn:hover {
  filter: brightness(1.04);
}

#startBtn:active,
.clear-btn:active,
.hud-btn:active,
.secondary-btn:active,
.segment-btn:active,
.mood-btn:active,
.swatch-btn:active {
  transform: translateY(1px);
}

.sub {
  display: block;
  margin: 14px auto 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.7;
}

#errorMsg {
  width: fit-content;
  max-width: min(100%, 560px);
  margin: 14px auto 0;
  padding: 10px 12px;
  border: 1px solid #f4b7b7;
  border-radius: 10px;
  background: var(--error-bg);
  color: var(--error-text);
  font-size: 10px;
  line-height: 1.6;
}

.welcome-clear {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 31;
  width: auto;
  max-width: calc(100vw - 28px);
  padding: 10px 12px;
  text-align: center;
}

/* ======================================
   SCENE SCREEN
====================================== */
#scene {
  position: relative;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  --side-rail: clamp(210px, 11.5vw, 240px);
}

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

#bgCanvas,
#fxCanvas,
#characterCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#bgCanvas {
  z-index: 0;
}

#fxCanvas {
  z-index: 35;
}

#characterCanvas {
  z-index: 18;
}

.hud {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.hud-top {
  position: absolute;
  inset: 0;
  display: block;
}

.hud-btn,
.age-label {
  pointer-events: auto;
}

.hud-btn {
  position: absolute;
  top: 18px;
  left: 18px;
  padding: 12px 18px;
  background: var(--btn2);
  color: #ffffff;
  box-shadow: var(--shadow);
  font-size: 11px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
}

.age-label {
  position: absolute;
  top: 18px;
  right: 18px;
  min-height: 48px;
  padding: 13px 16px;
  border-radius: var(--radius);
  background: var(--btn1);
  color: #073a3a;
  box-shadow: var(--shadow);
  font-size: 11px;
  line-height: 1.45;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.32);
}

.countdown-box {
  min-height: 48px;
  width: min(700px, calc(100vw - 420px));
  min-width: 300px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--panel-line);
  background: var(--panel-bg);
  box-shadow: var(--shadow);
  color: #f7fdff;
  font-size: 10px;
  line-height: 1.6;
  text-align: center;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.28);
}

.countdown-controls {
  margin-bottom: 6px;
  color: #c9d8df;
  font-size: 8px;
  line-height: 1.45;
}

.countdown-line {
  margin: 2px 0;
  color: #f7fdff;
}

.countdown-big {
  margin-top: 4px;
  color: #aef5ff;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.38),
    0 0 12px rgba(120, 201, 190, 0.42);
}

body[data-theme="night"] .countdown-big {
  color: #a9f0ff;
}

.scene-content {
  position: relative;
  z-index: 12;
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px var(--side-rail) 74px;
}

.scene-topbar {
  display: flex;
  justify-content: center;
  width: calc(100vw - 36px);
  margin: 0 0 26px calc(18px - var(--side-rail));
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
  width: min(1180px, 100%);
  margin: 0 auto;
}

.panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  background: var(--panel-bg);
  box-shadow: var(--shadow);
  color: #f7fdff;
  backdrop-filter: blur(12px);
}

.stats-panel,
.progress-panel {
  grid-column: span 7;
}

.milestones-panel,
.mood-panel {
  grid-column: span 5;
}

.mood-head-actions {
  display: inline-flex;
  align-items: center;
  justify-content: end;
  gap: 6px;
  min-width: 0;
}

.mood-panel .panel-head {
  gap: 8px;
}

.mood-panel .panel-chip {
  padding-inline: 8px;
  font-size: 7px;
}

.save-mood-btn {
  min-height: 30px;
  padding: 7px 8px;
  font-size: 7px;
  white-space: nowrap;
}

.customize-panel,
.settings-panel {
  grid-column: span 6;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel h2 {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: #f7fdff;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.34),
    0 0 12px rgba(120, 201, 190, 0.34);
}

.panel .field,
.panel .settings-message {
  color: #c9d8df;
}

.panel-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 7px 9px;
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #c9d8df;
  font-size: 8px;
  line-height: 1.4;
  white-space: nowrap;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}

body[data-theme="night"] .panel-chip {
  background: rgba(255, 255, 255, 0.08);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  min-height: 82px;
  padding: 12px;
  border-left: 4px solid var(--btn1);
  border-radius: 8px;
  background: var(--panel-item);
}

body[data-theme="night"] .metric {
  background: rgba(255, 255, 255, 0.07);
}

.metric:nth-child(2n) {
  border-left-color: var(--accent);
}

.metric:nth-child(3n) {
  border-left-color: var(--rose);
}

.metric-label {
  margin-bottom: 10px;
  color: #c8d8e0;
  font-size: 8px;
  line-height: 1.45;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.34);
}

.metric-value {
  color: #f7fdff;
  font-size: 15px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.36),
    0 0 10px rgba(120, 201, 190, 0.28);
}

.milestone-list,
.recent-list {
  display: grid;
  gap: 9px;
}

.milestone-item,
.recent-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  background: var(--panel-item);
}

body[data-theme="night"] .milestone-item,
body[data-theme="night"] .recent-item {
  background: rgba(255, 255, 255, 0.07);
}

.milestone-name,
.recent-main {
  color: #f7fdff;
  font-size: 9px;
  line-height: 1.55;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.34);
}

.milestone-meta,
.recent-note {
  color: #c9d8df;
  font-size: 8px;
  line-height: 1.45;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.26);
}

.milestone-pill {
  padding: 7px 8px;
  border-radius: 999px;
  background: var(--btn1);
  color: #073a3a;
  font-size: 8px;
  line-height: 1.2;
  white-space: nowrap;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.24);
}

.milestone-pill.done {
  background: var(--line);
  color: var(--muted);
}

.milestone-pill.today {
  background: var(--accent);
  color: #3a2b08;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  background: var(--panel-item);
}

.segment-btn {
  min-height: 30px;
  padding: 6px 10px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-size: 8px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

.segment-btn.is-active {
  background: var(--btn1);
  color: #073a3a;
}

.progress-summary {
  margin: 0 0 12px;
  color: #c9d8df;
  font-size: 9px;
  line-height: 1.6;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.28);
}

.progress-grid {
  display: grid;
  gap: 3px;
  align-items: center;
}

.year-grid {
  grid-template-columns: repeat(31, minmax(4px, 1fr));
}

.life-grid {
  grid-template-columns: repeat(52, minmax(3px, 1fr));
  max-height: 260px;
  overflow: auto;
  padding-right: 3px;
}

.progress-cell {
  aspect-ratio: 1;
  border-radius: 2px;
  background: rgba(120, 150, 160, 0.18);
}

.progress-cell.lived {
  background: var(--btn1);
}

.progress-cell.current {
  background: var(--accent);
}

.progress-cell.future {
  background: rgba(120, 150, 160, 0.18);
}

.mood-choices {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.mood-btn {
  min-height: 42px;
  padding: 9px 6px;
  border-color: var(--panel-line);
  background: rgba(31, 52, 72, 0.58);
  box-shadow: none;
  line-height: 1.3;
  color: #f7fdff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}

.mood-btn.is-active {
  border-color: var(--btn2);
  background: var(--btn1);
  color: #073a3a;
}

.note-field {
  margin-bottom: 10px;
}

.note-field input {
  width: 100%;
}

.control-group {
  margin-bottom: 14px;
}

.size-field {
  margin: 0 0 14px;
}

.size-field span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.size-field strong {
  color: #f7fdff;
  font-weight: normal;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.34);
}

.size-field input {
  width: 100%;
  min-height: 34px;
  padding: 0;
  box-shadow: none;
  accent-color: var(--btn1);
}

.control-label {
  margin-bottom: 8px;
  color: #c9d8df;
  font-size: 10px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}

.swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.swatch-btn {
  width: 38px;
  min-height: 38px;
  border: 3px solid rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow);
}

.swatch-btn.is-active {
  border-color: var(--ink);
}

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

.control-grid select {
  width: 100%;
}

.toggle-row,
.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toggle-row {
  margin-bottom: 14px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  background: var(--panel-item);
  color: #f7fdff;
  font-size: 9px;
  line-height: 1.45;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.32);
}

.toggle input {
  width: 18px;
  min-height: 18px;
  box-shadow: none;
}

.settings-message {
  min-height: 18px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.45;
}

.status-badge {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--soft);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
  user-select: none;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.26);
}

.welcome-status {
  position: fixed;
  bottom: 14px;
  left: 14px;
  z-index: 30;
}

.scene-status {
  width: fit-content;
  max-width: min(340px, 100%);
  margin-top: 14px;
}

/* ======================================
   GAME OVERLAY
====================================== */
.collectible-layer {
  position: absolute;
  inset: 0;
  z-index: 14;
  pointer-events: none;
}

.collectible {
  position: absolute;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  background: #f4c95d;
  box-shadow:
    0 4px 0 rgba(0, 0, 0, 0.18),
    0 0 14px rgba(244, 201, 93, 0.58);
  color: #654008;
  font-size: 10px;
  text-shadow: none;
  animation: coinBob 1.8s ease-in-out infinite;
}

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

.panel.is-discovered {
  border-color: rgba(244, 201, 93, 0.8);
  box-shadow:
    var(--shadow),
    0 0 0 2px rgba(244, 201, 93, 0.18),
    0 0 26px rgba(244, 201, 93, 0.24);
}

.panel.is-discovered h2::after {
  content: " found";
  color: var(--accent);
  font-size: 8px;
}

.quest-tracker,
.portal-dock,
.achievement-toast {
  position: fixed;
  z-index: 34;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(31, 52, 72, 0.82);
  box-shadow: var(--shadow);
  color: #f7fdff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
}

.quest-tracker {
  top: 112px;
  left: 46px;
  width: calc(var(--side-rail) - 64px);
  min-height: 252px;
  max-height: calc(100dvh - 136px);
  padding: 10px;
  display: grid;
  align-content: start;
  gap: 8px;
  font-size: 8px;
  overflow: auto;
}

.quest-item {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding-bottom: 3px;
}

.quest-title {
  color: #f7fdff;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.quest-progress {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.quest-progress span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--btn1), var(--accent));
}

.quest-item.done .quest-title {
  color: var(--accent);
}

.portal-dock {
  left: 46px;
  top: 212px;
  width: calc(var(--side-rail) - 64px);
  display: grid;
  gap: 8px;
  padding: 10px;
}

.portal-btn {
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: #f7fdff;
  cursor: pointer;
  font: inherit;
  font-size: 8px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.32);
}

.portal-btn:hover {
  background: rgba(120, 201, 190, 0.28);
}

.achievement-toast {
  left: 50%;
  top: 92px;
  transform: translateX(-50%);
  padding: 12px 16px;
  color: var(--accent);
  font-size: 9px;
}

.drawer-toggle {
  position: fixed;
  z-index: 35;
  display: grid;
  place-items: center;
  gap: 3px;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: rgba(31, 52, 72, 0.92);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.drawer-toggle span {
  display: block;
  width: 18px;
  height: 3px;
  border-radius: 999px;
  background: #f7fdff;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.32);
}

.quest-toggle {
  top: 118px;
  left: 0;
}

.portal-toggle {
  top: 168px;
  left: 0;
}

.quest-tracker,
.portal-dock {
  transition: transform 0.22s ease, opacity 0.22s ease;
  pointer-events: none;
}

.quest-tracker {
  transform: translateX(calc(-100% - 28px));
  opacity: 0;
}

.quest-tracker.is-open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.portal-dock {
  transform: translateX(calc(-100% - 56px));
  opacity: 0;
}

.portal-dock.is-open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 980px) {
  #scene {
    --side-rail: 0px;
  }

  .stats-panel,
  .progress-panel,
  .milestones-panel,
  .mood-panel,
  .customize-panel,
  .settings-panel {
    grid-column: 1 / -1;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .scene-content {
    padding: 86px 12px 74px;
  }

  .scene-topbar {
    width: 100%;
    margin-left: 0;
  }

  .dashboard-grid {
    width: min(720px, 100%);
    margin: 0 auto;
  }
}

@media (max-width: 720px) {
  #welcome {
    align-items: start;
    padding-top: 72px;
  }

  #welcome .title {
    font-size: 22px;
  }

  #welcome .hint {
    font-size: 11px;
  }

  .controls,
  .field,
  #bdayInput,
  #startBtn,
  .clear-btn {
    width: 100%;
  }

  .welcome-clear {
    width: auto;
  }

  .metric-grid,
  .control-grid {
    grid-template-columns: 1fr;
  }

  .mood-choices {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .year-grid {
    grid-template-columns: repeat(19, minmax(4px, 1fr));
  }

  .status-badge {
    max-width: calc(100vw - 28px);
    font-size: 8px;
  }

  .quest-tracker {
    top: 82px;
    left: 46px;
    width: min(230px, calc(100vw - 76px));
  }

  .portal-toggle {
    top: 132px;
  }

  .portal-dock {
    top: 180px;
    left: 46px;
    width: min(230px, calc(100vw - 76px));
  }
}

@media (max-width: 420px) {
  .hud-btn {
    top: 12px;
    left: 12px;
  }

  .age-label {
    top: 12px;
    right: 12px;
    min-height: 42px;
    padding: 11px 12px;
  }

  .countdown-box {
    width: min(300px, calc(100vw - 24px));
    min-width: 0;
  }

  .scene-content {
    padding: 84px 12px 74px;
  }

  .panel {
    padding: 13px;
  }

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

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

  .welcome-status {
    right: 10px;
    left: 10px;
    text-align: center;
  }
}
