:root {
  color-scheme: dark;
  --bg: #101215;
  --surface: #181b20;
  --surface-2: #21252b;
  --line: #343a43;
  --text: #e9edf2;
  --muted: #9aa5b3;
  --accent: #5ed0a4;
  --amber: #ffca66;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(94, 208, 164, 0.09), transparent 28rem),
    linear-gradient(180deg, #101215, #0b0c0f);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.app-shell {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  min-height: 76px;
}

.status-text {
  margin: 0 auto 0 0;
  color: #bdf7dc;
  font-size: 1rem;
  font-weight: 760;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.text-button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
  font: inherit;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.text-button[aria-pressed="true"],
.text-button[aria-current="page"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #111;
  font-weight: 700;
}

.text-button:hover {
  border-color: #747c88;
}

.text-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.cafeteria-stage {
  width: 100%;
  min-height: calc(100vh - 110px);
  display: grid;
  place-items: start center;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 10px;
}

canvas {
  width: min(100%, 1040px);
  min-width: 760px;
  height: auto;
  touch-action: none;
  border: 1px solid var(--line);
  background: #08090b;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.4);
}

.touch-controls {
  display: none;
}

.rotate-hint {
  display: none;
  margin: 0 0 8px;
  color: var(--amber);
  font-size: 0.88rem;
  font-weight: 760;
}

.rotate-hint[hidden] {
  display: none !important;
}

body[data-narrow="true"] .rotate-hint {
  display: block;
}

.test-shell {
  width: min(100%, 1120px);
}

.test-grid {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: 16px;
}

.test-results {
  background: rgba(24, 27, 32, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.test-results ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.test-results li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.9rem;
}

.test-results li.pass {
  color: #bdf7dc;
}

.test-results li.fail {
  color: #ffb8b8;
}

@media (max-width: 900px), (hover: none) and (pointer: coarse) {
  .app-shell {
    padding: 10px;
  }

  .topbar {
    min-height: 92px;
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
    gap: 6px;
  }

  .text-button {
    padding: 8px;
    font-size: 0.88rem;
  }

  .cafeteria-stage {
    min-height: calc(100vh - 118px);
    place-items: start start;
    padding-bottom: 116px;
  }

  .touch-controls {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 10;
    display: flex;
    align-items: end;
    justify-content: space-between;
    pointer-events: none;
  }

  .touch-cluster {
    pointer-events: auto;
  }

  .touch-cluster.move {
    display: grid;
    grid-template-columns: repeat(3, 48px);
    grid-template-rows: repeat(2, 48px);
    gap: 8px;
  }

  .touch-cluster.move .touch-btn:nth-child(1) {
    grid-column: 2;
  }

  .touch-cluster.move .touch-btn:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
  }

  .touch-cluster.move .touch-btn:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
  }

  .touch-cluster.move .touch-btn:nth-child(4) {
    grid-column: 3;
    grid-row: 2;
  }

.touch-btn {
    appearance: none;
    width: 48px;
    height: 48px;
    border: 1px solid rgba(189, 247, 220, 0.44);
    border-radius: 8px;
    background: rgba(24, 27, 32, 0.9);
    color: var(--text);
    font: inherit;
    font-size: 1rem;
    font-weight: 800;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
  }

  .action-btn {
    width: 64px;
    height: 64px;
    background: var(--accent);
    color: #111;
  }
}
