/* ============================================
   Casio VL-1 — 1:1 Layout (vl1-ipad2)
   - iPad/Desktop: echtes horizontales VL-1 Layout
   - iPhone-Portrait: Hybrid-Hint mit Link auf /vl1/ipad/
   ============================================ */

:root {
  --bg:         #14171a;
  --case:       #f4f1e8;
  --case-dark:  #d9d2c0;
  --case-edge:  #a99b80;
  --case-shadow:#5e533f;
  --bezel:      #1a1610;
  --bezel-edge: #2e2820;
  --lcd-bg:     #8da18a;
  --lcd-dim:    #647560;
  --lcd-text:   #1a1f17;
  --key-white:  #fafaf2;
  --key-white-edge: #c0bba6;
  --key-black:  #1c1814;
  --key-press:  #d97a3f;
  --btn-red:    #c93e2a;
  --btn-orange: #f2a23a;
  --btn-blue:   #4f93c4;
  --btn-blue-dk:#3c7aa6;
  --btn-gray:   #5b6168;
  --btn-gray-dk:#3b4046;
  --slider-bg:  #2a2620;
  --shadow:     0 8px 24px rgba(0,0,0,0.45);
  --font-lcd:   'Courier New', ui-monospace, monospace;
  --font-ui:    -apple-system, system-ui, 'Helvetica Neue', sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); font-family: var(--font-ui); color: #2a241c;
  -webkit-tap-highlight-color: transparent;
  user-select: none; overflow-x: hidden;
}

/* ---- Splash ---- */
.splash {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at center, #2a2d30 0%, #0a0c0e 100%);
  display: grid; place-items: center; z-index: 1000;
  transition: opacity .4s;
}
.splash.hidden { opacity: 0; pointer-events: none; }
.splash-inner { text-align: center; padding: 2rem; }
.splash-inner h1 {
  font-size: clamp(2rem, 6vw, 3.5rem);
  letter-spacing: 0.3em; margin: 0 0 .3rem; color: var(--case);
}
.tagline { color: #888; margin: 0 0 2rem; letter-spacing: .15em; font-size: .9rem; }
.power-btn {
  font-family: var(--font-ui); font-weight: 700; letter-spacing: .2em;
  padding: 1.2rem 2.5rem; background: var(--lcd-bg); color: var(--lcd-text);
  border: 3px solid var(--case-edge); border-radius: 12px;
  font-size: 1.1rem; cursor: pointer;
  box-shadow: var(--shadow); transition: transform .1s, background .2s;
}
.power-btn:hover { background: #a5bba0; }
.power-btn:active { transform: scale(0.97); }
.splash-inner .hint { color: #666; font-size: .8rem; margin-top: 1.5rem; }

/* ---- Device case ---- */
.device {
  max-width: 1280px; width: 96vw;
  margin: 2rem auto;
  padding: 1.5rem 1.5rem 2rem;
  background: var(--case);
  background-image: linear-gradient(180deg, #faf7ec 0%, #ece6d3 100%);
  border: 1px solid var(--case-edge);
  border-radius: 14px;
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255,255,255,.5),
    inset 0 -3px 8px rgba(94,83,63,.18);
  color: var(--case-shadow);
}

/* ===== TOP STRIP ===== */
.top-strip {
  display: grid;
  grid-template-columns: 1.05fr 1.1fr 3fr;
  gap: 1.2rem;
  margin-bottom: 1.5rem;
  align-items: stretch;
}

/* --- Speaker --- */
.speaker {
  background: linear-gradient(180deg, #ede5d0 0%, #d9d2c0 100%);
  border: 1px solid var(--case-edge);
  border-radius: 6px;
  padding: .8rem;
  min-height: 150px;
  box-shadow: inset 0 1px 1px rgba(255,255,255,.4), inset 0 -1px 2px rgba(0,0,0,.08);
}
.speaker-grille {
  width: 100%; height: 100%;
  background: repeating-linear-gradient(
    180deg,
    rgba(60,55,45,.55) 0px, rgba(60,55,45,.55) 2px,
    transparent 2px, transparent 6px
  );
}

/* --- LCD Bezel --- */
.lcd-bezel {
  background: var(--bezel);
  border: 2px solid var(--bezel-edge);
  border-radius: 8px;
  padding: .6rem .8rem;
  display: flex; flex-direction: column;
  position: relative;
  min-height: 150px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.05),
    inset 0 0 24px rgba(0,0,0,.4),
    0 2px 4px rgba(0,0,0,.2);
}
.lcd-bezel::before {
  content: ''; position: absolute; inset: -3px;
  border-radius: 10px;
  background: linear-gradient(180deg, #e8e8e8 0%, #888 50%, #e8e8e8 100%);
  z-index: -1;
}
.lcd-brand {
  color: #e0e0e0; font-weight: 700; letter-spacing: .15em;
  font-size: .82rem; text-align: center; margin-bottom: .35rem;
}
.lcd-wrap {
  flex: 1;
  display: flex; align-items: center; gap: .5rem;
  background: var(--lcd-bg);
  border: 1px inset rgba(0,0,0,.3);
  border-radius: 4px;
  padding: .4rem .6rem;
  min-height: 64px;
}
.lcd {
  flex: 1;
  font-family: var(--font-lcd); font-weight: 700;
  color: var(--lcd-text);
  font-size: 1.85rem;
  text-align: right;
  letter-spacing: .08em;
}
.beat-led {
  width: 12px; height: 12px; border-radius: 50%;
  background: rgba(0,0,0,.18);
  box-shadow: inset 0 1px 1px rgba(0,0,0,.3);
  transition: background .08s ease;
}
.beat-led.lit { background: #ff4d2a; box-shadow: 0 0 10px #ff4d2a, inset 0 1px 1px rgba(0,0,0,.15); }
.beat-led.faint { background: rgba(255,77,42,.5); }
.lcd-sub {
  color: #c8c0a8; font-size: .55rem; letter-spacing: .12em;
  text-align: center; margin-top: .3rem;
}

/* --- Control Panel --- */
.control-panel { display: flex; flex-direction: column; gap: .8rem; }

/* --- Slider Row --- */
.slider-row {
  display: grid;
  grid-template-columns: 1.1fr 1.1fr 1fr 1.2fr 1.1fr;
  gap: .65rem;
  align-items: end;
}
.vsl-slider, .vsl-discrete { display: flex; flex-direction: column; gap: .2rem; }
.vsl-label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: .58rem; letter-spacing: .12em; color: var(--case-shadow);
  font-weight: 700; text-transform: uppercase;
}
.vsl-hint { font-size: .55rem; opacity: .7; }
.vsl-name { flex: 1; text-align: center; }
.vsl-range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 18px;
  background: linear-gradient(180deg, #3a3530 0%, #1f1c18 100%);
  border-radius: 3px; border: 1px solid var(--case-shadow); outline: none;
}
.vsl-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 28px;
  background: linear-gradient(180deg, #4a4540 0%, #2a2620 100%);
  border-radius: 3px; border: 1px solid #1a1610;
  cursor: pointer;
  box-shadow:
    0 2px 4px rgba(0,0,0,.4),
    inset 0 1px 0 rgba(255,255,255,.15),
    inset 0 -2px 3px rgba(0,0,0,.25);
}
.vsl-range::-moz-range-thumb {
  width: 22px; height: 28px;
  background: linear-gradient(180deg, #4a4540 0%, #2a2620 100%);
  border-radius: 3px; border: 1px solid #1a1610; cursor: pointer;
}

.vsl-track {
  display: flex; gap: 2px;
  background: linear-gradient(180deg, #3a3530 0%, #1f1c18 100%);
  border-radius: 3px; border: 1px solid var(--case-shadow);
  padding: 2px; height: 28px;
}
.vsl-stop {
  flex: 1;
  background: linear-gradient(180deg, #5b5650 0%, #3a3530 100%);
  color: #ddd;
  border: 1px solid #1a1610; border-radius: 2px;
  font-family: var(--font-ui); font-weight: 700; font-size: .55rem;
  letter-spacing: .04em; cursor: pointer; padding: 0 .15rem;
  text-transform: uppercase;
}
.vsl-stop:hover { background: linear-gradient(180deg, #6b6660 0%, #4a4540 100%); }
.vsl-stop.active {
  background: linear-gradient(180deg, #f2cf72 0%, #d97a3f 100%);
  color: #1a1610;
  box-shadow: 0 0 0 1px #d97a3f, inset 0 1px 0 rgba(255,255,255,.3);
}

/* --- Function Row ---
   8 schmale hochkant Rechtecke + 2 breitere für ONE KEY PLAY. */
.func-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr) 1.55fr 1.55fr;
  gap: .4rem;
  align-items: stretch;
}
.func-btn {
  display: flex; flex-direction: column;
  align-items: center; justify-content: space-between;
  padding: .55rem .15rem .5rem;
  border: 1px solid var(--case-shadow);
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-ui); font-weight: 700; font-size: .55rem;
  letter-spacing: .03em; text-transform: uppercase; color: white;
  /* Hochkant: deutlich höher als breit */
  min-height: 96px;
  transition: transform .05s, filter .1s;
  box-shadow:
    0 2px 3px rgba(0,0,0,.25),
    inset 0 1px 0 rgba(255,255,255,.18),
    inset 0 -2px 4px rgba(0,0,0,.15);
}
.func-btn .func-top { line-height: 1.1; text-align: center; }
.func-btn .func-bot {
  font-size: .52rem; opacity: .85;
  padding-top: .25rem;
  border-top: 1px solid rgba(255,255,255,.18);
  width: 90%; text-align: center;
}
.func-btn.gray   { background: linear-gradient(180deg, var(--btn-gray) 0%, var(--btn-gray-dk) 100%); }
.func-btn.red    { background: linear-gradient(180deg, #d8553e 0%, var(--btn-red) 100%); }
.func-btn.orange { background: linear-gradient(180deg, #f5b864 0%, var(--btn-orange) 100%); }
.func-btn.blue   { background: linear-gradient(180deg, #65a8d4 0%, var(--btn-blue-dk) 100%); }

/* ONE KEY PLAY: breiter und höher, sonst gleiche rechteckige Form */
.func-btn.large {
  min-height: 110px;
  font-size: .65rem;
  padding: .7rem .25rem .65rem;
}
.func-btn.large .func-top {
  font-size: .7rem;
  /* dezenter Kreis als Print-Markierung wie im Original */
  position: relative;
}
.func-btn.large .func-top::before {
  content: '';
  display: block;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  border: 1.5px solid rgba(255,255,255,.55);
  margin: 0 auto .3rem;
}

.func-btn:hover { filter: brightness(1.1); }
.func-btn.pressed, .func-btn:active { transform: scale(.97); filter: brightness(.85); }
.func-btn.active { box-shadow: 0 0 0 2px #f2cf72, 0 2px 3px rgba(0,0,0,.25); }

/* ===== BOTTOM STRIP ===== */
.bottom-strip {
  background: linear-gradient(180deg, #2a241c 0%, #1a1610 100%);
  border: 2px solid var(--case-edge);
  border-radius: 10px;
  padding: 1rem .8rem .8rem;
  position: relative;
}
.key-strip { position: relative; height: 220px; }
.ks-whites {
  display: grid;
  grid-template-columns: repeat(17, 1fr);
  gap: 3px;
  height: 100%;
}
.ks-key {
  background: linear-gradient(180deg, var(--key-white) 0%, #e6e0c8 100%);
  border: 1px solid var(--key-white-edge);
  border-radius: 4px 4px 6px 6px;
  border-bottom: 4px solid #b8b09a;
  cursor: pointer;
  display: flex; flex-direction: column;
  justify-content: space-between; align-items: center;
  padding: .35rem .15rem .4rem;
  font-family: var(--font-ui); font-weight: 700; color: #2a241c;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.ks-key:hover { background: linear-gradient(180deg, #ffffff 0%, #f0e9d2 100%); }
.ks-key.pressed {
  background: linear-gradient(180deg, var(--key-press) 0%, #b3622e 100%);
  color: white;
  border-bottom-width: 2px;
  transform: translateY(2px);
}
.ks-key.rhy-active {
  background: linear-gradient(180deg, #f2cf72 0%, #e6b85c 100%);
}
.ks-rhythm {
  font-size: .5rem; letter-spacing: .04em;
  color: #5e533f; text-transform: uppercase; line-height: 1.1;
}
.ks-face { flex: 1; }
.ks-digit { font-size: .82rem; color: #2a241c; }
.ks-key.calc-only {
  background: linear-gradient(180deg, #f0ebda 0%, #d8d2bc 100%);
}
.ks-key.calc-only .ks-digit { font-size: 1rem; }

.ks-blacks { position: absolute; inset: 0; pointer-events: none; }
.ks-black {
  position: absolute;
  left: calc((var(--after) + 1) * (100% / 17) - (100% / 17 * 0.30));
  width: calc(100% / 17 * 0.60);
  top: 0; height: 58%;
  background: linear-gradient(180deg, #1c1814 0%, #050402 100%);
  border: 1px solid #050402;
  border-radius: 0 0 3px 3px;
  cursor: pointer; pointer-events: auto; z-index: 5;
  box-shadow: 0 4px 6px rgba(0,0,0,.4), inset 0 -3px 4px rgba(255,255,255,.06);
}
.ks-black:hover { background: linear-gradient(180deg, #2c2824 0%, #0a0805 100%); }
.ks-black.pressed {
  background: linear-gradient(180deg, var(--key-press) 0%, #8e4e26 100%);
  transform: translateY(2px);
}

/* ===== ADSR Panel ===== */
.adsr-panel {
  background: linear-gradient(180deg, #ede5d0 0%, #d9d2c0 100%);
  border: 1px solid var(--case-edge);
  border-radius: 8px;
  padding: 1rem; margin: 1rem 0;
  color: #2a241c;
}
.adsr-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .7rem; }
.group-label { font-size: .65rem; letter-spacing: .18em; color: #5e533f; font-weight: 700; }
.adsr-wave-name { color: var(--btn-orange); font-weight: 700; letter-spacing: .08em; font-size: .85rem; }
.adsr-body { display: grid; grid-template-columns: 1.8fr 1fr; gap: 1rem; align-items: start; }
.adsr-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: .25rem; }
.adsr-slot {
  background: linear-gradient(180deg, #fafaf2 0%, #e8e2d0 100%);
  border: 1px solid var(--case-edge);
  border-radius: 4px;
  padding: .35rem .15rem; text-align: center; cursor: pointer;
}
.adsr-slot.selected { box-shadow: 0 0 0 2px var(--btn-orange); }
.adsr-label { font-size: .55rem; letter-spacing: .08em; color: #5e533f; }
.adsr-digit { font-family: var(--font-lcd); font-size: 1.3rem; color: #2a241c; font-weight: 700; }
.adsr-hint { font-size: .5rem; opacity: .65; margin-top: .1rem; }
.adsr-numpad { display: grid; grid-template-columns: repeat(4, 1fr); gap: .25rem; }
.adsr-np-btn {
  padding: .5rem;
  background: linear-gradient(180deg, var(--btn-gray) 0%, var(--btn-gray-dk) 100%);
  color: white; border: 1px solid var(--btn-gray-dk); border-radius: 4px;
  font-family: var(--font-ui); font-weight: 700; font-size: .85rem;
  cursor: pointer; min-height: 36px;
}
.adsr-np-btn:hover { filter: brightness(1.1); }
.adsr-np-btn:active { transform: scale(.95); }
.adsr-np-btn.back, .adsr-np-btn.next {
  background: linear-gradient(180deg, #b08555 0%, #8a6238 100%);
}
.adsr-preset-row { display: flex; gap: .35rem; margin-top: .8rem; flex-wrap: wrap; }
.adsr-preset {
  flex: 1; min-width: 90px; padding: .45rem;
  background: linear-gradient(180deg, #b08555 0%, #8a6238 100%);
  color: #fff8e8; border: 1px solid #5e3e20; border-radius: 4px;
  font-size: .65rem; letter-spacing: .06em; cursor: pointer; font-weight: 700;
}
.adsr-preset:hover { background: linear-gradient(180deg, #c89a6a 0%, #a37246 100%); }
.adsr-hint-row { font-size: .7rem; color: #5e533f; margin: .8rem 0 0; }
.adsr-hint-row code {
  background: rgba(0,0,0,.1); padding: .1rem .4rem; border-radius: 3px;
  font-family: var(--font-lcd); color: #2a241c; letter-spacing: .1em;
}

/* ===== iOS Hint ===== */
.ios-hint { display: none; }

/* ===== RESPONSIVE ===== */

/* iPhone Portrait: zeige Hint, blende device aus */
@media (max-width: 767px) and (orientation: portrait) {
  body { background: #14171a; color: #ddd; }
  .device { display: none; }
  .splash { display: none; }
  .ios-hint {
    display: block;
    max-width: 480px; margin: 4rem auto; padding: 2rem;
    background: #1a1c20; border: 1px solid #3a3530; border-radius: 12px;
    text-align: center; color: #ddd;
  }
  .ios-hint p { margin: 1rem 0; line-height: 1.55; }
  .ios-hint a { color: var(--btn-orange); font-weight: 700; }
  .ios-hint .small { font-size: .85rem; opacity: .65; }
}

/* ---- iPhone Landscape: echter Vollbild-Modus, ganzes Board sichtbar, kein Scroll ----
   Device füllt 100% Viewport, alle Sektionen flex-shrinken proportional. */
@media (max-width: 1023px) and (orientation: landscape) and (max-height: 600px) {
  html, body {
    height: 100%;
    overflow: hidden;
    padding: 0; margin: 0;
    background: var(--bg);
  }
  body {
    /* Notch-safe-area-Berücksichtigung im Landscape (iPhone X+) */
    padding:
      env(safe-area-inset-top, 0)
      env(safe-area-inset-right, 0)
      env(safe-area-inset-bottom, 0)
      env(safe-area-inset-left, 0);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .device {
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    padding: .35rem .55rem .4rem;
    border-radius: 0;
    border: none;
    box-shadow: none;
    background-image: linear-gradient(180deg, #faf7ec 0%, #ece6d3 100%);
    display: flex; flex-direction: column;
    gap: .35rem;
  }

  /* Top: feste Höhe ~58% des Geräts */
  .top-strip {
    flex: 0 0 auto;
    gap: .4rem;
    grid-template-columns: .75fr 1fr 3.2fr;
    margin-bottom: 0;
    min-height: 0;
    max-height: 58%;
  }
  .speaker, .lcd-bezel { min-height: 0; }
  .lcd-bezel { padding: .3rem .45rem; }
  .lcd-brand { font-size: .55rem; margin-bottom: .15rem; }
  .lcd-wrap { padding: .25rem .4rem; min-height: 0; }
  .lcd { font-size: 1.05rem; }
  .lcd-sub { font-size: .42rem; margin-top: .15rem; letter-spacing: .08em; }
  .beat-led { width: 9px; height: 9px; }

  .control-panel { gap: .35rem; min-height: 0; }
  .slider-row {
    gap: .28rem;
    grid-template-columns: 1fr 1fr .9fr 1.2fr 1.1fr;
  }
  .vsl-label { font-size: .45rem; letter-spacing: .08em; }
  .vsl-hint { font-size: .42rem; }
  .vsl-range { height: 12px; }
  .vsl-range::-webkit-slider-thumb { width: 16px; height: 20px; }
  .vsl-track { height: 18px; padding: 1px; }
  .vsl-stop { font-size: .42rem; padding: 0 .08rem; }

  .func-row {
    gap: .22rem;
    grid-template-columns: repeat(8, 1fr) 1.35fr 1.35fr;
  }
  .func-btn {
    min-height: 48px;
    font-size: .42rem;
    padding: .25rem .08rem .22rem;
    border-radius: 3px;
  }
  .func-btn .func-bot {
    font-size: .38rem;
    padding-top: .1rem;
  }
  .func-btn.large {
    min-height: 56px;
    font-size: .48rem;
  }
  .func-btn.large .func-top::before {
    width: 11px; height: 11px;
    margin-bottom: .08rem;
    border-width: 1px;
  }

  /* Bottom: nimmt den Rest, immer flexibel */
  .bottom-strip {
    flex: 1 1 auto;
    padding: .45rem .35rem .35rem;
    border-radius: 6px;
    border-width: 1px;
    min-height: 0;
  }
  .key-strip { height: 100%; min-height: 0; }
  .ks-key { padding: .2rem .08rem .25rem; border-radius: 3px 3px 5px 5px; }
  .ks-rhythm { font-size: .34rem; letter-spacing: .02em; }
  .ks-digit { font-size: .55rem; }
  .ks-key.calc-only .ks-digit { font-size: .7rem; }
  .ks-black { height: 56%; }

  /* Splash auf iPhone-quer auch fullscreen */
  .splash { background: radial-gradient(ellipse at center, #2a2d30 0%, #0a0c0e 100%); }
  .splash-inner h1 { font-size: clamp(1.6rem, 7vw, 2.6rem); margin-bottom: .2rem; }
  .tagline { margin-bottom: 1rem; font-size: .75rem; }
  .power-btn { padding: .8rem 1.6rem; font-size: .9rem; }
  .splash-inner .hint { font-size: .7rem; margin-top: 1rem; }
}

/* iPad Portrait: voll, etwas kompakter */
@media (min-width: 768px) and (max-width: 1023px) and (orientation: portrait) {
  .device { padding: 1rem; }
  .top-strip { grid-template-columns: 1fr 1.1fr 2.6fr; }
  .key-strip { height: 180px; }
}

/* iPad Landscape + Desktop: 1:1 mit 3D-Perspektive */
@media (min-width: 1024px) and (orientation: landscape) {
  html, body { min-height: 100vh; }
  body {
    perspective: 2400px;
    perspective-origin: 50% 40%;
    padding: 2rem 0;
    display: flex; align-items: center; justify-content: center;
    background: radial-gradient(ellipse at center top, #1f2226 0%, #0a0c0e 65%);
  }
  .device {
    margin: 0;
    transform: rotateX(5deg) rotateY(-1deg);
    transform-origin: 50% 70%;
    transform-style: preserve-3d;
    box-shadow:
      0 50px 90px -20px rgba(0,0,0,0.78),
      0 24px 48px -15px rgba(0,0,0,0.55),
      0 0 0 1px var(--case-edge),
      inset 0 1px 0 rgba(255,255,255,0.5),
      inset 0 -4px 10px rgba(94,83,63,.2);
    transition: transform .5s ease;
  }
  .device:hover { transform: rotateX(3deg) rotateY(-0.3deg); }
}
