:root {
  color-scheme: dark;
  --bg: #071013;
  --panel: #0d1b20;
  --panel-2: #12272d;
  --ink: #f8fbf7;
  --muted: #a7b6b8;
  --line: #244047;
  --amber: #ffb238;
  --green: #39d98a;
  --cyan: #61d9e8;
  --red: #ff655f;
  --button: #0b6f7f;
  --brand: #f06418;
  --brand-2: #0fb6a8;
  --surface-glow: rgba(15, 182, 168, 0.16);
}

body[data-theme="light"] {
  color-scheme: light;
  --bg: #f7faf9;
  --panel: #ffffff;
  --panel-2: #eef5f3;
  --ink: #101816;
  --muted: #536462;
  --line: #bfd1cd;
  --amber: #9d5a00;
  --green: #087a45;
  --cyan: #007d8a;
  --red: #b42323;
  --button: #007d8a;
  --brand: #e35313;
  --brand-2: #007d73;
  --surface-glow: rgba(0, 125, 115, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(240, 100, 24, 0.12), transparent 220px),
    linear-gradient(135deg, rgba(15, 182, 168, 0.12), transparent 38%),
    var(--bg);
  color: var(--ink);
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 0 max(40px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

#boardPage {
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
}

.complete-view #boardPage {
  height: auto;
  max-height: none;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: visible;
}

#boardPage .topbar,
#boardPage .controls,
#boardPage .notice,
#boardPage .ad-zone,
#boardPage .app-footer {
  flex: 0 0 auto;
}

#boardPage .board {
  min-height: 0;
}

.complete-view #boardPage .board {
  min-height: 0;
  overflow: visible;
}

.topbar,
.controls,
.board {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent), var(--panel);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 22px 24px;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 18px 50px var(--surface-glow);
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.brand-logo {
  width: 118px;
  height: 78px;
  object-fit: contain;
  background: transparent;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.25));
}

.agency-heading {
  min-width: 0;
}

.agency-name {
  margin: 0;
  color: var(--ink);
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1.05;
  font-weight: 1000;
  text-transform: uppercase;
  text-shadow: 0 0 24px rgba(15, 182, 168, 0.26);
}

.agency-name::first-letter {
  color: var(--brand);
}

.agency-address {
  margin: 6px 0 8px;
  color: var(--cyan);
  font-size: 15px;
  line-height: 1.25;
  font-weight: 900;
  text-transform: uppercase;
}

.kicker {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: clamp(32px, 4vw, 46px);
  line-height: 1;
  letter-spacing: 0;
}

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

.header-actions > button,
.header-actions > .download-button {
  min-width: 132px;
}

.clock {
  display: grid;
  justify-items: end;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}

.top-actions {
  display: grid;
  justify-items: end;
  align-content: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 310px;
}

.utility-actions,
.contact-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.contact-actions {
  flex-wrap: nowrap;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  width: 42px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.icon-button.wide {
  min-width: 58px;
  width: 58px;
  font-size: 13px;
}

#clockTime {
  font-size: 38px;
  font-weight: 800;
}

#clockDate {
  color: var(--muted);
  font-size: 14px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  padding: 16px 24px;
  border-top: 0;
}

.mode-switch {
  display: flex;
  gap: 6px;
  height: 42px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #090c0f;
}

.mode-button {
  min-width: 96px;
  height: 32px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
}

.mode-button.active {
  background: linear-gradient(135deg, var(--brand), var(--amber));
  color: #17100a;
}

.current-route-notice {
  flex: 1 1 420px;
  align-self: center;
  color: var(--ink);
  font-size: clamp(18px, 2.1vw, 28px);
  line-height: 1.15;
  font-weight: 1000;
  text-transform: uppercase;
  padding-left: 14px;
  border-left: 5px solid var(--brand);
}

label {
  display: grid;
  gap: 6px;
  min-width: 230px;
  flex: 1 1 230px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 700;
}

select,
button,
.download-button,
.whatsapp-button,
input[type="date"] {
  height: 42px;
  border-radius: 6px;
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
}

select,
input[type="date"] {
  width: 100%;
  min-width: 0;
  background: #0e151c;
  padding: 0 34px 0 12px;
}

input[type="number"] {
  height: 42px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #0e151c;
  color: var(--ink);
  padding: 0 12px;
  font: inherit;
}

input[type="text"] {
  height: 42px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #0e151c;
  color: var(--ink);
  padding: 0 12px;
  font: inherit;
}

textarea {
  width: 100%;
  min-width: 0;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #0e151c;
  color: var(--ink);
  padding: 12px;
  font: inherit;
  resize: vertical;
}

button,
.download-button,
.maps-button,
.whatsapp-button {
  min-width: 116px;
  padding: 0 16px;
  background: linear-gradient(135deg, var(--button), #0a5660);
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
.download-button:hover,
.maps-button:hover,
.whatsapp-button:hover {
  border-color: var(--cyan);
}

.download-button,
.maps-button,
.whatsapp-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.download-button {
  background: linear-gradient(135deg, #9d5a00, var(--brand));
  color: #fff4dc;
}

.download-button:hover {
  border-color: var(--amber);
}

.maps-button {
  min-width: 196px;
  height: 52px;
  padding: 0 22px;
  background: linear-gradient(135deg, var(--brand), #a43e09);
  color: #eef7ff;
  font-size: 15px;
  font-weight: 1000;
  text-transform: uppercase;
}

.maps-button:hover {
  border-color: var(--cyan);
}

.whatsapp-button {
  background: linear-gradient(135deg, #128c4a, #087a45);
  color: #effff5;
}

.whatsapp-button:hover {
  border-color: var(--green);
}

.schedule-button {
  background: linear-gradient(135deg, var(--brand-2), #0b6f58);
  color: #edfff8;
}

.schedule-button:hover {
  border-color: var(--green);
}

.secondary-button {
  min-width: 116px;
  background: #182734;
}

.label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 800;
}

.route-picker {
  flex: 1 1 auto;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background:
    linear-gradient(180deg, rgba(15, 182, 168, 0.08), transparent 260px),
    var(--panel);
  padding: 22px;
  overflow: auto;
}

.route-cards {
  display: grid;
  gap: 22px;
}

.route-group {
  display: grid;
  gap: 12px;
}

.route-group h2 {
  margin: 0;
  color: var(--brand);
  font-size: 20px;
  text-transform: uppercase;
}

.route-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.route-choice {
  height: auto;
  min-height: 104px;
  display: grid;
  align-content: center;
  gap: 7px;
  padding: 14px;
  text-align: left;
  white-space: normal;
  background:
    linear-gradient(135deg, rgba(240, 100, 24, 0.14), transparent 58%),
    #0f1c21;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.route-choice span {
  color: var(--brand-2);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.route-choice strong {
  color: var(--ink);
  font-size: 20px;
  line-height: 1.15;
  text-transform: uppercase;
}

.route-choice small {
  color: var(--muted);
  font-size: 12px;
}

.board {
  flex: 1 1 auto;
  min-height: 260px;
  margin-top: 18px;
  max-width: 100%;
  overflow: hidden;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.22);
}

.board-head,
.row {
  display: grid;
  grid-template-columns: 120px minmax(420px, 1.8fr) minmax(280px, 1.2fr);
  align-items: stretch;
}

.board-head {
  display: none;
  background: #090c0f;
  color: var(--amber);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 900;
}

.board-head span,
.cell {
  padding: 13px 14px;
  border-right: 1px solid var(--line);
}

.board-head span:last-child,
.cell:last-child {
  border-right: 0;
}

.rows {
  display: grid;
  min-height: 0;
}

.schedule-columns {
  flex: 1 1 auto;
  height: 100%;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 10px;
  align-content: stretch;
  padding: 10px;
  overflow: hidden;
}

.complete-view .schedule-columns {
  height: auto;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  grid-auto-rows: auto;
  gap: 7px;
  padding: 8px;
  overflow: visible;
}

.schedule-card {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(255, 178, 56, 0.08), transparent 50%),
    #101a1f;
  overflow: hidden;
}

.complete-view .schedule-card {
  grid-template-rows: auto auto auto;
  gap: 5px;
  padding: 8px;
  border-radius: 6px;
}

.schedule-card:nth-child(even) {
  background:
    linear-gradient(180deg, rgba(15, 182, 168, 0.08), transparent 52%),
    #0c171b;
}

.schedule-time {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.schedule-route {
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
}

.schedule-arrivals {
  min-width: 0;
}

.row {
  min-height: 76px;
  border-top: 1px solid var(--line);
  background: #10161d;
}

.row:nth-child(even) {
  background: #0d1319;
}

.cell {
  display: grid;
  align-content: center;
  gap: 3px;
}

.time {
  color: var(--amber);
  font-size: clamp(25px, 3vw, 34px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.route {
  font-weight: 900;
}

.route-path {
  font-size: clamp(13px, 1.25vw, 16px);
  line-height: 1.35;
}

.sub {
  color: var(--muted);
  font-size: clamp(10px, 1vw, 12px);
}

.arrivals {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.arrival-chip {
  display: grid;
  gap: 2px;
  min-height: 38px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #090c0f;
}

.arrival-chip strong {
  color: var(--brand-2);
  font-variant-numeric: tabular-nums;
}

.arrival-chip span {
  color: var(--muted);
  font-size: 10px;
}

.large-text .time {
  font-size: clamp(31px, 4vw, 42px);
}

.large-text .route-path {
  font-size: clamp(16px, 1.7vw, 20px);
}

.large-text .sub,
.large-text .arrival-chip span {
  font-size: 13px;
}

.large-text .arrival-chip strong {
  font-size: 17px;
}

.complete-view .time {
  font-size: clamp(21px, 2.4vw, 28px);
}

.complete-view .route-path {
  font-size: clamp(11px, 1.05vw, 14px);
  line-height: 1.25;
}

.complete-view .sub {
  font-size: 10px;
  line-height: 1.25;
}

.complete-view .arrival-chip {
  min-height: 30px;
  padding: 5px;
}

.complete-view .arrival-chip strong {
  font-size: 12px;
}

.complete-view .arrival-chip span {
  font-size: 9px;
}

.empty,
.loading {
  padding: 42px 20px;
  text-align: center;
  color: var(--muted);
}

.notice {
  min-height: 24px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.ad-zone {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.035), transparent 55%),
    var(--panel);
}

.ad-zone-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.ad-banner {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 8px;
  background: #ffffff;
}

.board-ad-zone {
  margin-top: 10px;
  padding: 8px 10px;
}

.board-ad-zone .ad-banner {
  max-height: 110px;
}

.guide-page {
  min-height: 100vh;
}

.guide-panel {
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: var(--panel);
  padding: 24px;
}

.guide-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: end;
}

.guide-form label {
  min-width: 0;
}

.guide-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.master-form {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 16px;
  align-items: end;
}

.master-message {
  grid-column: 1 / -1;
}

.master-recent {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.master-recent-item {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0d1319;
}

.master-recent-item strong {
  color: var(--amber);
}

.master-recent-item span {
  color: var(--ink);
}

.master-recent-item small {
  color: var(--muted);
}

.app-footer {
  margin-top: 18px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(240, 100, 24, 0.1), rgba(15, 182, 168, 0.1)), #071113;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  text-align: center;
}

.app-footer small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  font-weight: 800;
}

.settings-panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 28px;
  padding:
    max(28px, env(safe-area-inset-top))
    max(28px, env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom))
    max(28px, env(safe-area-inset-left));
  background: rgba(0, 0, 0, 0.58);
}

.settings-panel.open {
  display: flex;
}

.settings-card {
  width: min(390px, 100%);
  display: grid;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.42);
}

.settings-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.settings-head h2 {
  margin: 3px 0 0;
  font-size: 28px;
}

.settings-logo {
  display: block;
  width: 110px;
  height: 70px;
  object-fit: contain;
  margin-bottom: 8px;
  background: transparent;
}

.check-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 15px;
  text-transform: none;
}

.check-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--amber);
}

.settings-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.settings-note {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #090c0f;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  font-weight: 800;
}

.release-note {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  font-weight: 900;
  text-transform: uppercase;
}

.release-note strong {
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}

body[data-theme="light"] .settings-note {
  background: #f5f7f9;
}

body[data-theme="light"] .mode-switch,
body[data-theme="light"] .board-head,
body[data-theme="light"] .app-footer,
body[data-theme="light"] .ad-zone,
body[data-theme="light"] .arrival-chip,
body[data-theme="light"] .notification-banner {
  background: #ffffff;
}

body[data-theme="light"] select,
body[data-theme="light"] input[type="date"],
body[data-theme="light"] input[type="number"],
body[data-theme="light"] input[type="text"],
body[data-theme="light"] textarea {
  background: #ffffff;
  color: var(--ink);
}

body[data-theme="light"] .route-choice,
body[data-theme="light"] .schedule-card,
body[data-theme="light"] .row,
body[data-theme="light"] .master-recent-item {
  background: #ffffff;
}

body[data-theme="light"] .schedule-card:nth-child(even),
body[data-theme="light"] .row:nth-child(even) {
  background: #f6f8fa;
}

.notification-banner {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  width: min(430px, calc(100% - 36px));
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--cyan);
  border-radius: 8px;
  background: #07131a;
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.42);
}

.notification-banner.urgent {
  border-color: var(--red);
}

.notification-banner strong,
.notification-banner span {
  display: block;
}

.notification-banner strong {
  color: var(--amber);
  font-size: 18px;
}

.notification-banner span {
  margin-top: 4px;
  color: var(--ink);
  line-height: 1.35;
}

.fullscreen-mode .app-shell {
  width: 100%;
  min-height: 100vh;
  padding: 14px;
}

.fullscreen-mode {
  overflow-x: hidden;
}

.fullscreen-mode .row {
  min-height: 82px;
}

.fullscreen-mode .time {
  font-size: 34px;
}

@media (max-width: 900px) {
  .app-shell {
    width: min(100% - 20px, 720px);
    padding-top: max(10px, env(safe-area-inset-top));
  }

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

  .topbar {
    display: grid;
  }

  .brand-title {
    align-items: flex-start;
  }

  .brand-logo {
    width: 100px;
    height: 68px;
  }

  .agency-name {
    font-size: 21px;
  }

  .agency-address {
    font-size: 12px;
  }

  .top-actions {
    justify-content: stretch;
    justify-items: stretch;
    min-width: 0;
  }

  .utility-actions,
  .contact-actions {
    justify-content: flex-end;
  }

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

  .controls {
    align-items: stretch;
  }

  .clock {
    justify-items: start;
  }

  .board-head {
    display: none;
  }

  .row {
    grid-template-columns: 1fr;
  }

  .cell {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    gap: 6px;
  }

  .cell::before {
    color: var(--amber);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
  }

  .row .cell:nth-child(1)::before {
    content: "Ora";
  }

  .row .cell:nth-child(2)::before {
    content: "Percorso";
  }

  .row .cell:nth-child(3)::before {
    content: "Arrivi";
  }

  .cell:last-child {
    border-bottom: 0;
  }

  .arrivals {
    grid-template-columns: 1fr;
  }

  .guide-form {
    grid-template-columns: 1fr;
  }

  .master-form {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 34px;
  }

  .settings-panel {
    padding: 10px;
    padding:
      max(10px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: 100%;
    padding-top: env(safe-area-inset-top);
  }

  .topbar,
  .controls,
  .route-picker,
  .board,
  .guide-panel,
  .ad-zone,
  .app-footer {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .topbar {
    gap: 14px;
    padding: 14px 14px;
  }

  .brand-title {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
  }

  .brand-logo {
    width: 76px;
    height: 54px;
  }

  .agency-name {
    font-size: 18px;
    line-height: 1.12;
  }

  .agency-address {
    margin-bottom: 6px;
    font-size: 11px;
  }

  .kicker {
    font-size: 10px;
  }

  h1 {
    font-size: 28px;
  }

  .top-actions {
    width: 100%;
    gap: 8px;
  }

  .utility-actions {
    order: 1;
    justify-content: flex-end;
  }

  .contact-actions {
    order: 2;
    display: grid;
    grid-template-columns: 1fr 1.35fr;
    width: 100%;
    gap: 8px;
  }

  .guide-page .top-actions {
    grid-template-columns: 1fr;
  }

  .route-page .top-actions {
    grid-template-columns: 1fr;
  }

  .whatsapp-button,
  .maps-button,
  .secondary-button {
    min-width: 0;
  }

  .maps-button {
    min-width: 0;
    height: 48px;
    padding: 0 10px;
    font-size: 12px;
  }

  .clock {
    order: 3;
    grid-column: 1 / -1;
    justify-items: start;
    padding-top: 2px;
  }

  #clockTime {
    font-size: 30px;
  }

  .header-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
  }

  .header-actions > button,
  .header-actions > .download-button {
    width: 100%;
    min-width: 0;
    padding: 0 8px;
    font-size: 12px;
  }

  .controls,
  .guide-panel {
    padding: 14px;
  }

  .mode-switch {
    width: 100%;
  }

  .mode-button {
    flex: 1 1 0;
    min-width: 0;
  }

  .current-route-notice {
    width: 100%;
    flex-basis: 100%;
    font-size: 18px;
  }

  label,
  .guide-actions > button,
  .guide-actions > .download-button {
    width: 100%;
    min-width: 0;
    flex: 1 1 100%;
  }

  .route-picker {
    padding: 14px;
  }

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

  .route-choice {
    min-height: 98px;
    padding: 11px;
  }

  .route-choice strong {
    font-size: 15px;
  }

  .board {
    margin-top: 12px;
    min-height: 330px;
  }

  .schedule-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 8px;
  }

  .complete-view .schedule-columns {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 6px;
  }

  .schedule-card {
    gap: 6px;
    padding: 9px;
  }

  .complete-view .schedule-card {
    padding: 6px;
  }

  .row {
    min-height: 0;
  }

  .cell {
    padding: 12px 14px;
  }

  .time {
    font-size: 26px;
  }

  .route-path {
    font-size: 13px;
  }

  .arrival-chip {
    min-height: 36px;
    padding: 6px;
  }

  .app-footer {
    margin-top: 12px;
    font-size: 12px;
  }

  .ad-zone {
    margin-top: 12px;
    padding: 10px;
  }

  .ad-banner {
    max-height: 150px;
    border-radius: 6px;
  }

  .board-ad-zone .ad-banner {
    max-height: 86px;
  }
}

@media (max-width: 380px) {
  .schedule-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .schedule-card {
    padding: 8px;
  }

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

  .time {
    font-size: 23px;
  }

  .route-path {
    font-size: 12px;
  }

  .sub,
  .arrival-chip span {
    font-size: 9px;
  }
}
