:root {
  color-scheme: light;
  --bg: #efebe4;
  --ink: #121212;
  --muted: #6f685d;
  --line: #d8d0c3;
  --panel: rgba(255, 252, 246, 0.94);
  --card: #ffffff;
  --black: #121212;
  --green: #1f7a4d;
  --red: #b74438;
  --yellow: #cf8b15;
  --blue: #235f87;
  --steel: #1e2329;
  --glass: rgba(255, 255, 255, 0.55);
  --shadow: 0 18px 48px rgba(31, 26, 20, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(35, 95, 135, 0.08), transparent 28%),
    linear-gradient(135deg, rgba(31, 122, 77, 0.06), transparent 32%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.app-shell {
  width: min(1220px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px 0 24px;
}

.utility-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.language-switcher {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255, 252, 246, 0.84);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  font-weight: 700;
}

.language-switcher select {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.screen {
  width: 100%;
}

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.lead {
  max-width: 680px;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.65;
}

.primary-action {
  color: #ffffff;
  background: var(--black);
  box-shadow: 0 12px 26px rgba(18, 18, 18, 0.18);
}

.secondary-action {
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
}

.danger-action {
  color: var(--red);
  background: #fff4f1;
  border: 1px solid #efc3bc;
}

.start-screen {
  min-height: calc(100vh - 40px);
  display: grid;
  align-content: center;
  gap: 26px;
}

.start-copy h1,
.result-header h1 {
  margin: 0;
  font-size: clamp(2.8rem, 7vw, 5.6rem);
  line-height: 0.95;
}

.setup-panel,
.top-bar,
.summary-panel,
.log-panel,
.phone-shell,
.dash-panel,
.setup-card,
.result-grid div,
.action-bar {
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.setup-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  background: var(--panel);
}

.setup-card h2,
.summary-panel h2,
.log-panel h2 {
  margin: 0;
  font-size: 1rem;
}

.goal-mode,
.speed-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toggle-chip,
.speed-chip {
  min-width: 72px;
  background: #ffffff;
  border: 1px solid var(--line);
}

.toggle-chip.active,
.speed-chip.active {
  color: #ffffff;
  background: var(--black);
  border-color: var(--black);
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 0.9rem;
  font-weight: 700;
}

.field-hint {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.start-card div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.start-card div:last-of-type {
  padding-bottom: 0;
}

.start-card span {
  color: var(--muted);
  font-weight: 700;
}

.start-card strong {
  font-size: 1.1rem;
}

.top-bar {
  position: sticky;
  top: 10px;
  z-index: 3;
  display: grid;
  grid-template-columns: 1.2fr repeat(3, minmax(110px, 1fr)) minmax(220px, 1.25fr);
  gap: 10px;
  padding: 10px;
  background: rgba(255, 252, 246, 0.84);
  backdrop-filter: blur(18px);
}

.brand-block,
.top-stat {
  min-height: 78px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.brand-block strong,
.top-stat strong {
  display: block;
  margin-top: 4px;
  font-size: 1.2rem;
}

.speed-control {
  display: grid;
  align-content: start;
  gap: 8px;
}

.top-speed-picker {
  gap: 6px;
}

.top-speed-picker .speed-chip {
  min-width: 0;
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.brand-block span,
.top-stat span,
.dash-panel span,
.phone-grid span,
.result-grid span,
dt {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.brand-block .eyebrow {
  margin-bottom: 4px;
}

.game-screen {
  display: grid;
  gap: 16px;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.dashboard-zone {
  display: grid;
  gap: 16px;
}

.road-stage {
  display: grid;
  gap: 16px;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(30, 35, 41, 0.02), rgba(30, 35, 41, 0.06)),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.dash-panel {
  display: grid;
  gap: 8px;
  min-height: 128px;
  padding: 16px;
  background: var(--card);
}

.dash-panel strong {
  font-size: 1.48rem;
}

.dash-panel small {
  color: var(--muted);
  line-height: 1.45;
}

.gauge {
  height: 12px;
  overflow: hidden;
  background: #ece3d7;
  border-radius: 999px;
}

.gauge i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--green), #7eb854);
  border-radius: inherit;
}

.phone-wrap {
  display: flex;
  justify-content: center;
  padding: 6px 0 0;
}

.phone-shell {
  width: min(390px, 100%);
  padding: 12px;
  background: linear-gradient(180deg, #1a1f26, #101318);
}

.phone-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px 14px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.84rem;
  font-weight: 700;
}

.phone-order-card {
  min-height: 510px;
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 18px;
  background: linear-gradient(180deg, #faf7f1, #f6efe4);
  border-radius: 28px;
}

.phone-order-card.idle {
  background: linear-gradient(180deg, #f0f1f4, #e8ebee);
}

.phone-label {
  margin: 0;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.phone-order-card h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 0.98;
}

.ride-note {
  min-height: 48px;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

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

.phone-grid div,
.result-grid div {
  min-height: 84px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.phone-grid strong,
.result-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 1.18rem;
}

.risk-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.risk-tags span {
  padding: 7px 10px;
  color: var(--green);
  background: #edf6ef;
  border: 1px solid #c8dfd0;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.risk-tags .risk {
  color: var(--red);
  background: #fff3f0;
  border-color: #efc3bc;
}

.phone-actions,
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: auto;
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  background: rgba(255, 252, 246, 0.84);
}

.side-zone {
  display: grid;
  gap: 16px;
}

.summary-panel,
.log-panel {
  padding: 16px;
  background: var(--panel);
}

dl {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
}

dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

dd {
  margin: 0;
  font-weight: 900;
}

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

.log-header span {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: right;
}

#event-log {
  display: grid;
  gap: 10px;
  min-height: 420px;
  max-height: 650px;
  overflow: auto;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

#event-log li {
  padding: 11px 12px;
  color: var(--muted);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.42;
}

#event-log .stat-entry {
  color: var(--ink);
  background: #f7f1e6;
}

.result-screen {
  min-height: calc(100vh - 40px);
  display: grid;
  align-content: center;
  gap: 18px;
}

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

#share-text {
  width: 100%;
  min-height: 116px;
  padding: 14px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
  line-height: 1.5;
}

@media (max-width: 1020px) {
  .setup-panel,
  .game-layout,
  .driver-dashboard,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .top-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    position: static;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 16px, 1220px);
    padding-top: 10px;
  }

  .start-copy h1,
  .result-header h1 {
    font-size: 2.6rem;
  }

  .phone-grid,
  .phone-actions,
  .result-actions,
  .action-bar,
  .top-bar {
    grid-template-columns: 1fr;
  }

  .phone-actions,
  .result-actions,
  .action-bar {
    display: grid;
  }

  .top-bar {
    display: grid;
  }
}
