:root {
  --bg-white: #FFFFFF;
  --bg-surface: #F8FAFC;
  --accent-yellow: #FACC15;
  --accent-tosca: #14B8A6;
  --matte-black: #18181B;
  --danger-red: #EF4444;
  --info-blue: #3B82F6;
  --muted-gray: #64748B;
  --border-soft: #E2E8F0;
  --font-pixel: 'Silkscreen', cursive, monospace;
  --font-mono: 'Space Mono', monospace;
  --pixel-border: 3px solid var(--matte-black);
  --pixel-shadow: 4px 4px 0px var(--matte-black);
  --pixel-shadow-pressed: 2px 2px 0px var(--matte-black);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  min-height: 100%;
  background-color: var(--bg-white);
  background-image: radial-gradient(#E2E8F0 1.5px, transparent 1.5px);
  background-size: 16px 16px;
  color: var(--matte-black);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.55;
  overflow-x: hidden;
}

h1, h2, h3, h4, .pixel-font {
  font-family: var(--font-pixel);
  letter-spacing: -0.02em;
  line-height: 1.3;
}

svg.pixel-icon {
  display: inline-block;
  vertical-align: middle;
  shape-rendering: crispEdges;
  flex-shrink: 0;
}

.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

.view-section {
  display: none;
  min-height: 100vh;
  animation: pixelFadeIn 0.2s steps(4, end);
}

.view-section.active {
  display: block;
}

@keyframes pixelFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.pixel-card {
  background: var(--bg-white);
  border: var(--pixel-border);
  box-shadow: var(--pixel-shadow);
  padding: 18px;
  position: relative;
}

.pixel-card-surface {
  background: var(--bg-surface);
  border: var(--pixel-border);
  box-shadow: var(--pixel-shadow);
  padding: 16px;
}

.pixel-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-pixel);
  font-size: 13px;
  font-weight: 700;
  padding: 12px 18px;
  border: var(--pixel-border);
  box-shadow: var(--pixel-shadow);
  background: var(--bg-white);
  color: var(--matte-black);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.12s ease;
  user-select: none;
  text-align: center;
}

.pixel-btn:hover:not(:disabled) {
  filter: brightness(0.98);
}

.pixel-btn:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: var(--pixel-shadow-pressed);
}

.pixel-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.pixel-btn-yellow {
  background: var(--accent-yellow);
  color: var(--matte-black);
}

.pixel-btn-tosca {
  background: var(--accent-tosca);
  color: var(--bg-white);
}

.pixel-btn-dark {
  background: var(--matte-black);
  color: var(--bg-white);
}

.pixel-btn-danger {
  background: var(--danger-red);
  color: var(--bg-white);
}

.pixel-btn-locked {
  background: #E2E8F0;
  color: #64748B;
  border-color: #475569;
  box-shadow: 4px 4px 0px #475569;
}

.pixel-btn-sm {
  font-size: 11px;
  padding: 8px 12px;
}

.pixel-btn-block {
  width: 100%;
}

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

.form-label {
  display: block;
  font-family: var(--font-pixel);
  font-size: 11px;
  margin-bottom: 6px;
  color: var(--matte-black);
}

.pixel-input,
.pixel-select {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 10px 12px;
  background: var(--bg-white);
  color: var(--matte-black);
  border: var(--pixel-border);
  box-shadow: 3px 3px 0px var(--matte-black);
  outline: none;
  border-radius: 0;
  appearance: none;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.pixel-input:focus,
.pixel-select:focus {
  background: #FEFCE8;
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0px var(--matte-black);
}

.pixel-select {
  background-image: linear-gradient(45deg, transparent 50%, var(--matte-black) 50%),
    linear-gradient(135deg, var(--matte-black) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 10px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.pixel-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-pixel);
  font-size: 10px;
  padding: 4px 9px;
  border: 2px solid var(--matte-black);
  box-shadow: 2px 2px 0px var(--matte-black);
  background: var(--bg-white);
  color: var(--matte-black);
}

.badge-yellow { background: var(--accent-yellow); color: var(--matte-black); }
.badge-tosca { background: var(--accent-tosca); color: var(--bg-white); }
.badge-dark { background: var(--matte-black); color: var(--bg-white); }
.badge-red { background: var(--danger-red); color: var(--bg-white); }
.badge-blue { background: var(--info-blue); color: var(--bg-white); }

.top-header {
  background: var(--matte-black);
  color: var(--bg-white);
  border-bottom: 4px solid var(--accent-yellow);
  padding: 12px 0;
  position: sticky;
  top: 0;
  z-index: 40;
}

.top-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.brand-title {
  font-family: var(--font-pixel);
  font-size: 16px;
  color: var(--bg-white);
}

.brand-title span {
  color: var(--accent-yellow);
}

.hero-section {
  padding: 36px 0 28px;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: center;
}

@media (min-width: 768px) {
  .hero-grid {
    grid-template-columns: 1.35fr 0.9fr;
  }
}

.hero-title {
  font-size: clamp(24px, 5vw, 38px);
  margin: 14px 0 12px;
  color: var(--matte-black);
}

.hero-title .highlight-yellow {
  background: var(--accent-yellow);
  padding: 0 6px;
  border: 2px solid var(--matte-black);
  display: inline-block;
}

.hero-title .highlight-tosca {
  background: var(--accent-tosca);
  color: var(--bg-white);
  padding: 0 6px;
  border: 2px solid var(--matte-black);
  display: inline-block;
}

.hero-desc {
  font-size: 14px;
  color: #334155;
  margin-bottom: 22px;
}

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

@media (min-width: 560px) {
  .hero-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

.mascot-stage {
  background: var(--bg-surface);
  border: var(--pixel-border);
  box-shadow: var(--pixel-shadow);
  padding: 24px 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.mascot-float {
  animation: pixelBob 1.8s steps(2, end) infinite;
  display: inline-block;
}

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

.mascot-stats {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mini-stat-box {
  background: var(--bg-white);
  border: 2px solid var(--matte-black);
  padding: 6px 4px;
  font-size: 11px;
}

.mini-stat-box strong {
  display: block;
  font-family: var(--font-pixel);
  font-size: 12px;
  color: var(--accent-tosca);
}

.steps-section {
  padding: 12px 0 48px;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  margin-bottom: 16px;
}

.steps-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 768px) {
  .steps-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  font-family: var(--font-pixel);
  font-size: 14px;
  background: var(--accent-yellow);
  border: var(--pixel-border);
  box-shadow: 2px 2px 0px var(--matte-black);
  margin-bottom: 12px;
}

.register-wrap {
  padding: 24px 0 48px;
}

.register-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}

@media (min-width: 768px) {
  .register-grid {
    grid-template-columns: 1.2fr 0.9fr;
  }
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.calc-preview-card {
  position: sticky;
  top: 76px;
}

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

.calc-metric {
  background: var(--bg-surface);
  border: 2px solid var(--matte-black);
  padding: 10px;
}

.calc-metric-label {
  font-size: 10px;
  font-family: var(--font-pixel);
  color: var(--muted-gray);
  margin-bottom: 4px;
}

.calc-metric-val {
  font-family: var(--font-pixel);
  font-size: 17px;
  color: var(--matte-black);
}

.dashboard-body {
  padding: 20px 0 100px;
}

@media (min-width: 768px) {
  .dashboard-body {
    padding: 20px 0 48px;
  }
}

.desktop-tabs {
  display: none;
  background: var(--bg-surface);
  border-bottom: var(--pixel-border);
  padding: 10px 0;
  position: sticky;
  top: 56px;
  z-index: 35;
}

@media (min-width: 768px) {
  .desktop-tabs {
    display: block;
  }
}

.desktop-tabs-inner {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.nav-tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 6px;
  background: var(--bg-white);
  border: 2px solid var(--matte-black);
  box-shadow: 2px 2px 0px var(--matte-black);
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--matte-black);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.nav-tab-btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0px var(--matte-black);
}

.nav-tab-btn.active {
  background: var(--accent-tosca);
  color: var(--bg-white);
}

.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-white);
  border-top: 3px solid var(--matte-black);
  z-index: 50;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}

@media (min-width: 768px) {
  .mobile-bottom-nav {
    display: none;
  }
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px;
  background: var(--bg-surface);
  border: 2px solid var(--matte-black);
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--matte-black);
  cursor: pointer;
  text-align: center;
}

.mobile-nav-item.active {
  background: var(--accent-tosca);
  color: var(--bg-white);
  transform: translateY(-2px);
  box-shadow: 2px 2px 0px var(--matte-black);
}

.dash-panel {
  display: none;
  animation: pixelFadeIn 0.18s steps(3, end);
}

.dash-panel.active {
  display: block;
}

.rpg-bar-wrap {
  width: 100%;
  height: 28px;
  background: var(--bg-surface);
  border: var(--pixel-border);
  position: relative;
  overflow: hidden;
  margin: 8px 0;
}

.rpg-bar-fill {
  height: 100%;
  background: var(--accent-tosca);
  width: 0%;
  transition: width 0.35s steps(10, end), background-color 0.2s ease;
  position: relative;
}

.rpg-bar-fill.warning {
  background: var(--accent-yellow);
}

.rpg-bar-fill.over {
  background: var(--danger-red);
}

.rpg-bar-grid {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    90deg,
    transparent 0px,
    transparent 16px,
    rgba(24, 24, 27, 0.2) 16px,
    rgba(24, 24, 27, 0.2) 18px
  );
  pointer-events: none;
}

.rpg-bar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--matte-black);
  text-shadow: 1px 1px 0px var(--bg-white), -1px -1px 0px var(--bg-white), 1px -1px 0px var(--bg-white), -1px 1px 0px var(--bg-white);
  pointer-events: none;
}

.macro-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.macro-box {
  background: var(--bg-surface);
  border: 2px solid var(--matte-black);
  padding: 10px;
}

.macro-mini-bar {
  height: 10px;
  background: var(--bg-white);
  border: 2px solid var(--matte-black);
  margin-top: 6px;
  overflow: hidden;
}

.macro-mini-fill {
  height: 100%;
  transition: width 0.3s steps(8, end);
}

.water-glasses-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
}

@media (min-width: 600px) {
  .water-glasses-grid {
    grid-template-columns: repeat(8, 1fr);
  }
}

.water-glass-btn {
  background: var(--bg-surface);
  border: var(--pixel-border);
  box-shadow: 3px 3px 0px var(--matte-black);
  padding: 10px 4px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.15s ease;
}

.water-glass-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0px var(--matte-black);
}

.water-glass-btn.filled {
  background: #CCFBF1;
}

.water-cup-visual {
  width: 34px;
  height: 40px;
  border: 3px solid var(--matte-black);
  background: var(--bg-white);
  position: relative;
  overflow: hidden;
}

.water-cup-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0%;
  background: var(--accent-tosca);
  transition: height 0.28s steps(5, end);
}

.water-glass-btn.filled .water-cup-fill {
  height: 82%;
  box-shadow: inset 0 4px 0px #5EEAD4;
}

.quick-food-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}

@media (min-width: 640px) {
  .quick-food-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.quick-food-card {
  background: var(--bg-white);
  border: var(--pixel-border);
  box-shadow: 3px 3px 0px var(--matte-black);
  padding: 10px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.quick-food-card:hover {
  background: #FEFCE8;
}

.quick-food-card:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0px var(--matte-black);
}

.scan-preview-frame {
  width: 100%;
  min-height: 230px;
  max-height: 360px;
  background: var(--bg-surface);
  border: var(--pixel-border);
  box-shadow: inset 0 0 0 4px var(--bg-white);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  margin: 14px 0;
  padding: 12px;
  text-align: center;
}

.scan-preview-frame img {
  max-width: 100%;
  max-height: 320px;
  object-fit: contain;
  border: 2px solid var(--matte-black);
}

.scan-laser {
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent-tosca);
  box-shadow: 0 0 10px var(--accent-tosca);
  animation: scanMove 1.4s linear infinite;
  display: none;
}

.scan-preview-frame.scanning .scan-laser {
  display: block;
}

@keyframes scanMove {
  0% { top: 6%; }
  50% { top: 92%; }
  100% { top: 6%; }
}

.scan-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ai-result-card {
  margin-top: 16px;
  background: var(--bg-white);
  border: var(--pixel-border);
  box-shadow: var(--pixel-shadow);
  padding: 16px;
}

.health-score-pills {
  display: flex;
  gap: 3px;
  margin-top: 4px;
}

.score-block {
  width: 14px;
  height: 14px;
  border: 2px solid var(--matte-black);
  background: var(--bg-surface);
}

.score-block.active-good { background: var(--accent-tosca); }
.score-block.active-mid { background: var(--accent-yellow); }
.score-block.active-low { background: var(--danger-red); }

.camera-video-wrap {
  width: 100%;
  background: #09090B;
  border: var(--pixel-border);
  overflow: hidden;
  margin-bottom: 12px;
  position: relative;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.quest-item {
  background: var(--bg-white);
  border: var(--pixel-border);
  box-shadow: var(--pixel-shadow);
  padding: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.quest-item.completed {
  background: #F0FDFA;
  border-color: var(--matte-black);
}

.quest-checkbox {
  width: 28px;
  height: 28px;
  border: var(--pixel-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg-surface);
}

.quest-item.completed .quest-checkbox {
  background: var(--accent-tosca);
  color: var(--bg-white);
}

.log-item {
  background: var(--bg-white);
  border: var(--pixel-border);
  box-shadow: 3px 3px 0px var(--matte-black);
  padding: 12px 14px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.log-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.chat-window {
  height: 360px;
  overflow-y: auto;
  background: var(--bg-surface);
  border: var(--pixel-border);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.chat-bubble {
  max-width: 86%;
  padding: 10px 12px;
  border: 2px solid var(--matte-black);
  box-shadow: 3px 3px 0px var(--matte-black);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-bubble.ai {
  align-self: flex-start;
  background: var(--bg-white);
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--accent-yellow);
}

.chat-quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.chat-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 5px 8px;
  background: var(--bg-surface);
  border: 2px solid var(--matte-black);
  cursor: pointer;
}

.chat-chip:hover:not(:disabled) {
  background: var(--accent-yellow);
}

.chat-chip:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-input-row {
  display: flex;
  gap: 8px;
}

.player-id-card {
  background: var(--matte-black);
  color: var(--bg-white);
  border: var(--pixel-border);
  box-shadow: 6px 6px 0px var(--accent-yellow);
  padding: 18px;
  margin-bottom: 18px;
}

.player-id-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 14px;
}

@media (min-width: 600px) {
  .player-id-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.player-id-stat {
  background: #27272A;
  border: 2px solid #52525B;
  padding: 10px;
}

.pixel-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24, 24, 27, 0.78);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.pixel-modal-backdrop.open {
  display: flex;
}

.pixel-modal-box {
  width: 100%;
  max-width: 460px;
  background: var(--bg-white);
  border: 4px solid var(--matte-black);
  box-shadow: 8px 8px 0px var(--matte-black);
  padding: 20px;
  animation: pixelFadeIn 0.16s steps(3, end);
}

.pixel-toast {
  position: fixed;
  top: 70px;
  right: 16px;
  z-index: 120;
  background: var(--matte-black);
  color: var(--bg-white);
  border: 3px solid var(--accent-yellow);
  box-shadow: 4px 4px 0px var(--matte-black);
  padding: 10px 14px;
  font-family: var(--font-pixel);
  font-size: 11px;
  max-width: 320px;
  display: none;
}

.pixel-toast.show {
  display: block;
  animation: pixelFadeIn 0.15s steps(3, end);
}

.stack-gap {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.text-muted {
  color: var(--muted-gray);
  font-size: 12px;
}

.hidden-input {
  display: none;
}
