:root {
  color-scheme: light;
  --ink: #242321;
  --muted: #625c55;
  --paper: #fff8e7;
  --surface: #ffffff;
  --line: #d6c8ad;
  --sky: #afe8f3;
  --deep-sky: #4a8fc1;
  --teal: #126f75;
  --teal-dark: #0a4e54;
  --coral: #c95d48;
  --gold: #e3ac3f;
  --leaf: #2f7d5a;
  --shadow: 0 18px 42px rgba(36, 35, 33, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background:
    linear-gradient(90deg, rgba(18, 111, 117, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(201, 93, 72, 0.08) 1px, transparent 1px),
    var(--paper);
  background-size: 44px 44px;
}

button,
a {
  color: inherit;
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 850;
  letter-spacing: 0;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

button:hover:not(:disabled),
button:focus-visible:not(:disabled) {
  outline: none;
  transform: translateY(-1px);
  box-shadow: 4px 4px 0 rgba(36, 35, 33, 0.18);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.fall-shell {
  display: grid;
  gap: 18px;
  width: min(1180px, calc(100% - 36px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 0 34px;
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 22px;
  align-items: center;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  width: fit-content;
  color: var(--teal-dark);
  font-size: 0.9rem;
  font-weight: 900;
  text-decoration: none;
  text-transform: uppercase;
}

.brand-mark {
  position: relative;
  display: inline-block;
  width: 46px;
  aspect-ratio: 1;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 62%, var(--ink) 0 5px, transparent 6px),
    #f2c15e;
  box-shadow: 5px 5px 0 var(--leaf);
}

.brand-ear {
  position: absolute;
  top: -5px;
  width: 17px;
  height: 24px;
  border: 2px solid var(--ink);
  background: #c9882d;
}

.brand-ear-left {
  left: 4px;
  border-radius: 14px 6px 11px 6px;
  transform: rotate(-22deg);
}

.brand-ear-right {
  right: 4px;
  border-radius: 6px 14px 6px 11px;
  transform: rotate(22deg);
}

.brand-eye,
.brand-nose {
  position: absolute;
  border-radius: 50%;
  background: var(--ink);
}

.brand-eye {
  top: 20px;
  width: 5px;
  height: 5px;
}

.brand-eye-left {
  left: 13px;
}

.brand-eye-right {
  right: 13px;
}

.brand-nose {
  left: 19px;
  top: 28px;
  width: 8px;
  height: 6px;
}

.title-lockup {
  min-width: 0;
}

.eyebrow,
.score-label,
.fall-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 2px 0 0;
  font-size: 3rem;
  line-height: 0.98;
  letter-spacing: 0;
}

.action-row,
.touch-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.selector-link,
.action-row button,
.touch-controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 17px;
}

.selector-link {
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--surface);
  font-weight: 850;
  text-decoration: none;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

.selector-link:hover,
.selector-link:focus-visible {
  outline: none;
  transform: translateY(-1px);
  box-shadow: 4px 4px 0 rgba(36, 35, 33, 0.18);
}

.primary-button {
  background: var(--teal);
  color: #ffffff;
}

.scorebar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(142px, 1fr));
  gap: 12px;
}

.score-tile {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(36, 35, 33, 0.09);
}

.score-tile strong {
  overflow: hidden;
  font-size: 1.7rem;
  line-height: 1;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-panel {
  display: grid;
  gap: 12px;
}

.canvas-frame {
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--sky);
  box-shadow: var(--shadow);
}

canvas {
  display: block;
  width: 100%;
  min-height: 360px;
  max-height: 640px;
  aspect-ratio: 16 / 9;
}

.lower-bar {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.fall-status {
  min-height: 1.3em;
}

@media (max-width: 780px) {
  .fall-shell {
    width: min(100% - 24px, 1180px);
    padding-top: 18px;
  }

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

  h1 {
    font-size: 2.35rem;
  }

  .action-row,
  .touch-controls {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
  }

  .touch-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  canvas {
    min-height: 430px;
    aspect-ratio: 4 / 5;
  }

  .lower-bar {
    display: grid;
  }
}

@media (max-width: 430px) {
  .scorebar {
    gap: 8px;
  }

  .score-tile {
    padding: 12px;
  }

  .score-tile strong {
    font-size: 1.35rem;
  }

  .selector-link,
  .action-row button,
  .touch-controls button {
    padding: 0 10px;
  }
}
