@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap');
/* Theme variables: light by default, toggle by adding .dark on body */
:root {
  --bg: #E3F2FD;
  --wrapper-bg: #141414;
  --text: #141414;
  --muted: #A2A2A2;
}
body.dark {
  --bg: #0f1112;
  --wrapper-bg: #0b0b0b;
  --text: #e6e6e6;
  --muted: #bdbdbd;
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
}
body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  transition: background 0.2s ease, color 0.2s ease;
}
.wrapper {
  padding: 35px 40px;
  border-radius: 20px;
  background: var(--wrapper-bg);
  color: var(--muted);
  transition: background 0.2s ease, color 0.2s ease;
}
.wrapper header {
  display: flex;
  color: #B2B2B2;
  align-items: center;
  justify-content: space-between;
}
header h2 {
  font-size: 1.6rem;
}
header .column {
  display: flex;
  align-items: center;
}

/* Menu button (hidden on desktop) */
.menu-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
}
header span {
  font-weight: 500;
  margin-right: 15px;
  font-size: 1.19rem;
}
header input {
  outline: none;
  border-radius: 30px;
}
.volume-slider input {
  accent-color: #fff;
}
.keys-checkbox input {
  height: 30px;
  width: 60px;
  cursor: pointer;
  appearance: none;
  position: relative;
  background: #4B4B4B
}
.keys-checkbox input::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #8c8c8c;
  transform: translateY(-50%);
  transition: all 0.3s ease;
}
.keys-checkbox input:checked::before {
  left: 35px;
  background: #fff;
}
.piano-keys {
  display: flex;
  list-style: none;
  margin-top: 40px;
}
.piano-keys .key {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  position: relative;
  text-transform: uppercase;
}
.piano-keys .black {
  z-index: 2;
  width: 44px;
  height: 140px;
  margin: 0 -22px 0 -22px;
  border-radius: 0 0 5px 5px;
  background: linear-gradient(#333, #000);
}
.piano-keys .black.active {
  box-shadow: inset -5px -10px 10px rgba(255,255,255,0.1);
  background:linear-gradient(to bottom, #000, #434343);
}
.piano-keys .white {
  height: 230px;
  width: 70px;
  border-radius: 8px;
  border: 1px solid #000;
  background: linear-gradient(#fff 96%, #eee 4%);
}
.piano-keys .white.active {
  box-shadow: inset -5px 5px 20px rgba(0,0,0,0.2);
  background:linear-gradient(to bottom, #fff 0%, #eee 100%);
}
.piano-keys .key span {
  position: absolute;
  bottom: 20px;
  width: 100%;
  color: var(--muted);
  font-size: 1.13rem;
  text-align: center;
}
.piano-keys .key.hide span {
  display: none;
}
.piano-keys .black span {
  bottom: 13px;
  color: #888888;
}
@media screen and (max-width: 815px) {
  .wrapper {
    padding: 25px;
  }
  header {
    flex-direction: column;
  }
  /* On small screens we hide header title (we show only menu button) */
  header h2 { display: none; }
  .menu-btn { display: block; position: absolute; top: 14px; left: 14px; z-index: 40; }
  /* Controls-panel becomes hidden by default; toggled via .open */
  .controls-panel { display: none; }
  .controls-panel.open { display: flex; flex-direction: column; gap: 12px; background: rgba(0,0,0,0.6); padding: 12px; border-radius: 10px; position: fixed; top: 56px; left: 12px; right: 12px; z-index: 50; }
  .controls-panel .column { background: rgba(255,255,255,0.03); padding: 10px; border-radius: 8px; }
  header :where(h2, .column) {
    margin-bottom: 13px;
  }
  .volume-slider input {
    max-width: 100px;
  }
  .piano-keys {
    margin-top: 20px;
  }
  .piano-keys .key:where(:nth-child(9), :nth-child(10)) {
    display: none;
  }
  .piano-keys .black {
    height: 100px;
    width: 40px;
    margin: 0 -20px 0 -20px;
  }
  .piano-keys .white {
    height: 180px;
    width: 60px;
  }
}
@media screen and (max-width: 615px) {
  .piano-keys .key:nth-child(13),
  .piano-keys .key:nth-child(14),
  .piano-keys .key:nth-child(15),
  .piano-keys .key:nth-child(16),
  .piano-keys .key :nth-child(17) {
    display: none;
  }
  .piano-keys .white {
    width: 50px;
  }
}

/* Mobile portrait rotation and sizing + larger keys + 85% sizing */
@media (max-width: 900px) and (orientation: portrait) {
  /* make wrapper take 85% of the viewport short-side (portrait -> height)
     then rotate so it looks landscape. This keeps desktop unaffected. */
  .wrapper {
    width: 85vh; /* 85% of screen height (so when rotated it appears 85% wide) */
    max-width: 85vh;
    padding: 18px;
    transform: rotate(90deg);
    transform-origin: center center;
  }
  .piano-keys { margin-top: 12px; }
  /* Make keys larger on mobile for easier tapping */
  .piano-keys .white { width: 80px; height: 240px; }
  .piano-keys .black { width: 52px; height: 160px; margin: 0 -26px 0 -26px; }
  /* Hide header contents on mobile except menu (we positioned it absolute) */
  header { position: relative; height: 0; }
  header h2 { display: none; }
  /* Controls-panel overlay style when opened (keeps outside rotated wrapper) */
  .controls-panel { display: none; }
  .controls-panel.open { display: flex; }
}

/* Footer styles */
.site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 8px;
  display: flex;
  justify-content: center;
  pointer-events: auto;
}
.footer-inner {
  background: transparent;
  color: var(--muted);
  font-size: 0.86rem;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 6px 12px;
  border-radius: 12px;
}
.dev-credit { opacity: 0.85; }

/* Tiny toggle switch */
.tiny-toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.tiny-toggle input { opacity: 0; width: 0; height: 0; }
.tiny-toggle .slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #cfcfcf; transition: .2s; border-radius: 22px; }
.tiny-toggle .slider:before { content: ""; position: absolute; height: 18px; width: 18px; left: 2px; top: 2px; background: white; border-radius: 50%; transition: .2s; }
.tiny-toggle input:checked + .slider { background: #444; }
.tiny-toggle input:checked + .slider:before { transform: translateX(18px); }

/* Rotate the piano UI automatically on small portrait screens so it appears landscape */
@media (max-width: 900px) and (orientation: portrait) {
  /* lock body and center */
  body {
    height: 100vh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  /* rotate the main wrapper to landscape */
  .wrapper {
    transform: rotate(90deg);
    transform-origin: center center;
    /* try to size the rotated wrapper so it fits the viewport */
    width: calc(100vh - 40px);
    max-width: calc(100vh - 40px);
    box-shadow: none;
  }
  /* keep the footer readable (footer is outside .wrapper) */
  .site-footer { pointer-events: auto; }
}