:root{
  --bg: #0b0f14;
  --card: #111826;
  --muted: #95a3b7;
  --text: #e8eef8;
  --accent: #4cc9f0;
  --danger: #ff4d4d;

  --radius: 18px;
  --shadow: 0 12px 40px rgba(0,0,0,.35);
}

*{ box-sizing: border-box; }
html, body { height: 100%; }

body{
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background:
    radial-gradient(1200px 800px at 50% -20%, rgba(76,201,240,.15), transparent 60%),
    radial-gradient(900px 700px at 120% 10%, rgba(114,9,183,.12), transparent 55%),
    var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.app{
  min-height: 100%;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom) 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 520px;
  margin: 0 auto;
}

/* Top bar */
.topbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px;
  background: rgba(17,24,38,.65);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.brand{
  font-weight: 700;
  letter-spacing: .2px;
  font-size: 16px;
}

.top-actions{
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Layout wrapper (switches in landscape) */
.layout{
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Dial */
.dial{
  background: rgba(17,24,38,.72);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 16px 16px 16px;
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.dial::before{
  content:"";
  position:absolute;
  inset:-50%;
  background: conic-gradient(from 180deg, rgba(76,201,240,.28), rgba(255,255,255,.02), rgba(76,201,240,.10));
  filter: blur(30px);
  opacity: .5;
  transform: rotate(12deg);
  pointer-events: none;
}

.speed{
  position: relative;
  z-index: 1;
  display:flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  padding: 10px 0 6px;
}

.speed-value{
  font-size: clamp(72px, 18vw, 120px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -1px;
  text-shadow: 0 10px 30px rgba(0,0,0,.4);
}

.speed-unit{
  font-size: 18px;
  color: var(--muted);
  font-weight: 700;
}

.sub{
  position: relative;
  z-index: 1;
  display:flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.chip{
  flex: 1;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 14px;
  padding: 10px 12px;
  min-width: 0;
}

.chip-label{
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.chip-value{
  font-size: 20px;
  font-weight: 800;
}

/* Panel */
.panel{
  background: rgba(17,24,38,.65);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  backdrop-filter: blur(10px);
}

.row{
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.item{
  flex: 1;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 14px;
  padding: 10px 12px;
}

.label{
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.value{
  font-size: 16px;
  font-weight: 700;
}

.controls{
  display:flex;
  gap: 10px;
  margin-top: 10px;
}

/* Buttons */
.btn{
  appearance: none;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.06);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 14px;
  font-weight: 750;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

.btn:active{ transform: translateY(1px); }

.btn-ghost{
  background: transparent;
}

.btn-danger{
  border-color: rgba(255,77,77,.4);
  background: rgba(255,77,77,.14);
}

.btn:disabled{
  opacity: .45;
  cursor: not-allowed;
}

.hint{
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

/* =========================
   LANDSCAPE: Speed is hero
   ========================= */
@media (orientation: landscape) {
  .app{
    max-width: 900px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .layout{
    flex-direction: row;
    align-items: stretch;
    gap: 14px;
    flex: 1;
  }

  /* Dial takes most of the width */
  .dial{
    flex: 1.8;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 18px 16px;
    min-height: calc(100vh - 110px);
  }

  /* Panel becomes compact sidebar */
  .panel{
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: calc(100vh - 110px);
  }

  /* Bigger speed digits */
  .speed-value{
    font-size: clamp(96px, 18vw, 170px);
  }

  .speed-unit{
    font-size: 20px;
  }

  /* Compact secondary stats */
  .sub{
    margin-top: 14px;
  }

  .chip{
    padding: 8px 10px;
  }

  .chip-value{
    font-size: 18px;
  }

  .row{
    margin-bottom: 8px;
  }

  .item{
    padding: 8px 10px;
  }

  /* Hide hint to reduce clutter */
  .hint{
    display: none;
  }
}

/* Extra: very short landscape screens */
@media (orientation: landscape) and (max-height: 420px){
  .speed-value{
    font-size: clamp(84px, 16vw, 140px);
  }
  .dial, .panel{
    min-height: unset;
  }
}

/* =========================================
   RESPONSIVE LAYOUT SWITCH (robust)
   - Works on landscape OR wide screens
   ========================================= */

@media (orientation: landscape), (min-width: 740px) {
  .layout{
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 14px;
    flex: 1;
  }

  .dial{
    flex: 1.8;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: calc(100vh - 110px);
  }

  .panel{
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: calc(100vh - 110px);
  }

  /* Make speed the hero */
  .speed-value{
    font-size: clamp(96px, 16vw, 180px);
  }

  .hint{
    display: none;
  }

  /* OPTIONAL DEBUG: uncomment to confirm mode switching */
  /* .topbar { outline: 2px solid lime; } */
}
