:root {
  color-scheme: light dark;
  --accent: #fcb827;
  --accent-soft: #feeabf;
  --background: #fefcf9;
  --surface: rgba(255, 255, 255, 0.72);
  --text: #222;
  --muted: #666;
  --border: rgba(34, 34, 34, 0.18);
  --danger: #b42318;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
::selection { background: var(--accent-soft); color: #222; }
[hidden] { display: none !important; }

body {
  background: var(--background);
  color: var(--text);
  margin: 0;
  min-height: 100vh;
  transition: background-color 0.2s, color 0.2s;
}

body.dark {
  --background: #1c1c1e;
  --surface: rgba(44, 44, 46, 0.85);
  --text: #f5f5f5;
  --muted: #aaa;
  --border: rgba(255, 255, 255, 0.2);
  --danger: #ffb4ab;
}

a { color: var(--accent); }
button, input { font: inherit; }
input, select, textarea { font-size: 16px; }
button { color: inherit; }
.visually-hidden { clip: rect(0 0 0 0); clip-path: inset(50%); height: 1px; overflow: hidden; position: absolute; white-space: nowrap; width: 1px; }

.background {
  background: linear-gradient(rgba(0, 0, 0, 0.46), rgba(0, 0, 0, 0.46)), url("https://images.unsplash.com/photo-1517248135467-4c7edcad34c4?auto=format&fit=crop&w=1950&q=80") center/cover no-repeat;
  filter: blur(8px);
  inset: -12px;
  position: fixed;
  z-index: -1;
}

.phone-frame, .phone-screen { all: unset; }
.notch, .status-bar { display: none; }

.app-container {
  background: var(--background);
  min-height: 100vh;
  padding: 1rem;
}

.header {
  align-items: center;
  background: var(--background);
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
  margin: 0 -0.5rem;
  padding: 0 0.5rem 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header__title { color: var(--accent); font-weight: 700; }
.header__back { align-items: center; display: flex; gap: 0.35rem; font-weight: 700; text-decoration: none; }
.header__actions { align-items: center; display: flex; gap: 0.15rem; }
.header__actions button {
  background: transparent;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  min-height: 44px;
  min-width: 40px;
}

.menu-dropdown {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  display: grid;
  padding: 0.4rem;
  position: absolute;
  right: 0.5rem;
  top: 48px;
  width: max-content;
  z-index: 20;
}

.menu-dropdown button { background: transparent; border: 0; border-radius: 7px; cursor: pointer; padding: 0.7rem; text-align: left; }
.menu-dropdown button:hover, .menu-dropdown button:focus-visible { background: var(--surface); }

.app-scroll-content { min-width: 0; }
.datetime { color: var(--muted); font-size: 0.85rem; font-weight: 500; margin-bottom: 0.3rem; text-align: center; }
h1 { font-size: 2rem; line-height: 1.15; margin: 0 0 1rem; }
h2 { line-height: 1.25; }
p, li { line-height: 1.5; }

.home-list { display: grid; }
.home-list a {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0.8rem;
  min-height: 52px;
  padding: 0.5rem;
  text-decoration: none;
}

.home-list a:first-child { border-top: 1px solid var(--border); }
.home-list i { width: 1.25rem; }

.note-section { border-top: 1px solid var(--border); }
.note-section__toggle {
  align-items: center;
  background: transparent;
  border: 0;
  cursor: pointer;
  display: flex;
  font-weight: 700;
  gap: 0.75rem;
  min-height: 52px;
  padding: 0.75rem;
  text-align: left;
  width: 100%;
}

.note-section__content { padding: 0 1rem 1rem; }
.chevron { transition: transform 0.2s; width: 1rem; }
.chevron.rotate { transform: rotate(90deg); }

.panel, .result-card, details.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

.panel + .panel, .panel + details, details + details { margin-top: 1rem; }
.panel h2, .result-card h2 { font-size: 1.1rem; margin: 0 0 0.8rem; }
.intro, .hint { color: var(--muted); }
.intro { margin-top: 0; }
.hint { font-size: 0.9rem; }

.form-grid { display: grid; gap: 0.9rem; }
.form-grid label { display: grid; font-size: 0.95rem; font-weight: 600; gap: 0.4rem; }
.input-with-unit { align-items: center; display: flex; gap: 0.5rem; font-size: 0.9rem; font-weight: 400; }
input[type="number"], input[type="tel"], input[type="text"] {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: inherit;
  min-height: 44px;
  min-width: 0;
  padding: 0.65rem 0.8rem;
  width: 100%;
}

input:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(252, 184, 39, 0.42);
  outline-offset: 2px;
}

.button, button.button {
  align-items: center;
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 10px;
  color: var(--accent);
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  gap: 0.5rem;
  justify-content: center;
  min-height: 44px;
  padding: 0.65rem 1rem;
  text-decoration: none;
}

.button:disabled { cursor: wait; opacity: 0.6; }
.button-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; }
.error { color: var(--danger); }

.result-card { border-color: var(--accent); margin: 1rem 0; }
.result-card output { color: var(--accent); display: block; font-size: 1.8rem; font-weight: 700; overflow-wrap: anywhere; }
.price-grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.price-grid div { display: grid; gap: 0.35rem; }
.price-grid span { color: var(--muted); font-size: 0.85rem; }
.price-grid strong { color: var(--accent); font-size: 1.6rem; }

details.card { padding: 0; }
details.card summary { cursor: pointer; font-weight: 700; padding: 1rem; }
details.card > :not(summary) { margin-left: 1rem; margin-right: 1rem; }
details.card > :last-child { margin-bottom: 1rem; }

.breakdown { margin: 0 1rem 1rem; }
.breakdown div { align-items: baseline; border-top: 1px solid var(--border); display: flex; gap: 1rem; justify-content: space-between; padding: 0.7rem 0; }
.breakdown dt, .breakdown dd { margin: 0; }
.breakdown dd { font-variant-numeric: tabular-nums; text-align: right; }
.breakdown .total { font-weight: 700; }

.contact-links { display: grid; gap: 0.6rem; list-style: none; margin: 1rem 0 0; padding: 0; }
.contact-links a { align-items: center; display: flex; gap: 0.5rem; font-weight: 700; text-decoration: none; }
.contact-reveal { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: 1rem; }
.contact-email { font-weight: 700; min-height: 1.5rem; }

.software-card + .software-card { margin-top: 1rem; }
.software-card h2 { margin-top: 0; }

.html-resources { display: grid; gap: 0.75rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 1rem; }
.hints-grid { display: grid; gap: 1rem; }
.html-hint h2 { font-size: 1.1rem; margin-top: 0; }
code {
  background: rgba(127, 127, 127, 0.14);
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  overflow-wrap: anywhere;
  padding: 0.15rem 0.35rem;
}
.code-block { display: block; padding: 0.65rem; }
.heading-demo { align-items: baseline; display: flex; flex-wrap: wrap; gap: 0.7rem; }
.heading-demo span { font-weight: 700; }
.heading-demo span:nth-child(1) { font-size: 2rem; }
.heading-demo span:nth-child(2) { font-size: 1.7rem; }
.heading-demo span:nth-child(3) { font-size: 1.45rem; }
.heading-demo span:nth-child(4) { font-size: 1.2rem; }
.heading-demo span:nth-child(5) { font-size: 1rem; }
.heading-demo span:nth-child(6) { font-size: 0.85rem; }
.alignment-demo { display: grid; gap: 0.35rem; }
.alignment-demo span:nth-child(2) { text-align: center; }
.alignment-demo span:nth-child(3) { text-align: right; }

.coin-stage { min-height: 110px; padding: 1rem; text-align: center; perspective: 1000px; }
.coin { color: #bfa76f; font-size: 64px; transform-style: preserve-3d; }
.coin.flip { animation: spin-coin 1.25s ease-in-out forwards; }
@keyframes spin-coin { 0% { transform: rotateY(0) scale(1); } 50% { transform: rotateY(720deg) scale(1.15); } 100% { transform: rotateY(1440deg) scale(0); } }
.presentation-mode { border-width: 0 !important; border-radius: 0 !important; height: 100vh !important; width: 100vw !important; }

.canvas-wrapper { display: flex; justify-content: center; overflow: hidden; width: 100%; }
#konami-snake { border: 2px solid var(--border); height: auto; max-width: 100%; }
.robot { animation: float 3s ease-in-out infinite; color: var(--muted); font-size: 1.1rem; line-height: 1.4; margin: 2rem auto; width: min-content; }
@keyframes float { 50% { transform: translateY(-8px); } }

.toast {
  background: #333;
  border-radius: 8px;
  bottom: 20px;
  color: #fff;
  left: 50%;
  opacity: 0;
  padding: 0.75rem 1rem;
  pointer-events: none;
  position: fixed;
  transform: translateX(-50%);
  transition: opacity 0.2s;
  width: max-content;
  max-width: calc(100vw - 2rem);
  z-index: 100;
}
.toast.show { opacity: 1; }

@media (min-width: 600px) {
  body { align-items: center; display: flex; justify-content: center; min-height: 100vh; }
  .phone-frame {
    background: var(--background);
    border: 16px solid #333;
    border-radius: 40px;
    box-shadow: 0 0 0 8px #888;
    display: block;
    height: 800px;
    overflow: hidden;
    position: relative;
    width: 480px;
  }
  .notch { background: #222; border-radius: 0 0 20px 20px; display: block; height: 30px; left: 50%; position: absolute; top: 0; transform: translateX(-50%); width: 120px; z-index: 30; }
  .status-bar { align-items: center; background: var(--background); color: var(--text); display: flex; font-size: 0.85rem; height: 30px; justify-content: space-between; padding: 0 10px; position: absolute; top: 0; width: 100%; z-index: 20; }
  .status-icons { align-items: center; display: flex; gap: 10px; }
  .phone-screen { display: block; height: calc(100% - 30px); overflow-y: auto; padding-top: 30px; scrollbar-width: none; width: 100%; }
  .phone-screen::-webkit-scrollbar { display: none; }
  .app-container { min-height: 100%; padding-top: 0; }
}

@media (max-width: 420px) {
  .price-grid, .html-resources { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}

.giving-breakdown { border-collapse: collapse; table-layout: fixed; width: 100%; }
.giving-breakdown caption { text-align: left; }
.giving-breakdown th, .giving-breakdown td { border-bottom: 1px solid var(--border); padding: 0.85rem 0.2rem; text-align: right; }
.giving-breakdown th:first-child { text-align: left; width: 38%; }
.giving-breakdown thead th { color: var(--muted); font-size: 0.8rem; font-weight: 500; }
.giving-breakdown tbody th { font-size: 0.9rem; font-weight: 500; }
.giving-breakdown small { color: var(--muted); display: block; font-size: 0.75rem; margin-top: 0.25rem; }
.giving-breakdown td { font-size: clamp(0.75rem, 3.5vw, 1rem); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.giving-breakdown tfoot { font-weight: 700; }
.giving-breakdown tfoot th, .giving-breakdown tfoot td { border-bottom: 0; padding-top: 1rem; }
.giving-reconciliation { border-top: 1px solid var(--border); color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; line-height: 1.6; margin: 0; padding-top: 0.85rem; text-align: center; }
.giving-reconciliation strong { font-weight: 500; }
