/* cabbage.css */
:root{
  /* LIGHT MODE */
  --bg: #ffffff;
  --panel: rgba(0,0,0,.04);
  --stroke: rgba(0,0,0,.14);
  --text: rgba(0,0,0,.92);
  --muted: rgba(0,0,0,.68);
  --shadow: 0 18px 55px rgba(0,0,0,.18);
  --btn: rgba(0,0,0,.06);

  --bad: #ff1d25;
  --good: #7ac943;

  /* ROYGBIV (starting on C) */
  --c: #ff0000;
  --d: #ff7a00;
  --e: #ffd200;
  --f: #00c853;
  --g: #0087ff;
  --a: #4b0082;
  --b: #8f00ff;
}

*{ box-sizing:border-box; }
html,body{
  height:100%;
  margin:0;

  overflow:hidden;

  touch-action: manipulation;
  -ms-touch-action: manipulation;

  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/* ✅ FULLSCREEN BLACK BACKGROUND FIX
   Browsers often paint a black backdrop behind the fullscreen element.
   Because our panels use rgba(...) transparency, they look dark/black in fullscreen
   unless the fullscreen element itself has a solid white background. */
.app{
  background: #ffffff;
}
#appRoot:fullscreen,
#appRoot:-webkit-full-screen{
  background: #ffffff;
}
:fullscreen{
  background: #ffffff;
}

/* Main layout */
.app{
  height: calc(var(--vh, 1vh) * 100);
  width:100%;

  display:grid;

  /* ✅ Give staff the flexible space, and make the input area auto-sized (removes empty space) */
  grid-template-rows: minmax(220px, 1fr) auto auto auto;

  gap: 10px;

  padding: 10px;
  padding-top: calc(10px + env(safe-area-inset-top));
  padding-bottom: calc(10px + env(safe-area-inset-bottom));

  overflow:auto;
  -webkit-overflow-scrolling: touch;
}

.app::-webkit-scrollbar{ width:0; height:0; }

/* Staff */
.staffArea{
  min-height: 220px;
  border: 2px solid rgba(0,0,0,.70);
  background: #ffffff;
  box-shadow: var(--shadow);
  overflow:hidden;
}
.staffMount{ height: 100%; width: 100%; }

/* HUD */
.hud{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap: 10px;
}
.hudLeft, .hudRight{
  display:flex;
  gap: 10px;
  align-items:center;
  flex-wrap: wrap;
}
.pill{
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 10px 12px;
  display:flex;
  gap: 10px;
  align-items:baseline;
  box-shadow: 0 10px 28px rgba(0,0,0,.12);
}
.pill .label{ color: var(--muted); font-weight: 900; font-size: 12px; }
.pill .value{ font-weight: 1000; font-size: 18px; color: var(--text); }

/* Teacher difficulty select */
.selectWrap{
  display:flex;
  flex-direction:column;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 16px;
  background: rgba(0,0,0,.04);
  border: 1px solid rgba(0,0,0,.14);
  box-shadow: 0 12px 30px rgba(0,0,0,.10);
}
.selectLabelSmall{
  font-size: 11px;
  font-weight: 1000;
  color: rgba(0,0,0,.70);
  letter-spacing: .2px;
}
.select{
  appearance:none;
  -webkit-appearance:none;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.18);
  background: rgba(0,0,0,.05);
  color: rgba(0,0,0,.92);
  font-weight: 900;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}

/* Answer */
.answerArea{
  border: 1px solid var(--stroke);
  background: var(--panel);
  border-radius: 16px;
  padding: 10px;
  box-shadow: 0 12px 36px rgba(0,0,0,.10);
}
.slots{
  display:flex;
  gap: 10px;
  justify-content:center;
  align-items:center;
  flex-wrap: wrap;
  padding: 6px 0 10px;
}
.slot{
  width: 68px;
  height: 68px;
  border-radius: 14px;
  border: 2px solid rgba(0,0,0,.14);
  background: rgba(0,0,0,.05);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 36px;
  font-weight: 1000;
  color: rgba(0,0,0,.92);
  text-shadow: none;
  transition: transform .10s ease, box-shadow .10s ease, outline .10s ease, filter .10s ease;
}
.slot.active{
  outline: 6px solid rgba(0,0,0,.22);
  outline-offset: 2px;
}
.slot.playing{
  transform: scale(1.03);
  box-shadow: 0 0 0 8px rgba(0,0,0,.10), 0 18px 40px rgba(0,0,0,.16);
  filter: brightness(1.02);
}
.slot.filled{
  color: #ffffff;
  text-shadow: 0 6px 14px rgba(0,0,0,.35);
}
.message{
  min-height: 26px;
  text-align:center;
  font-weight: 1000;
  color: rgba(0,0,0,.90);
}

/* Input */
.inputArea{
  position: relative;
  border: 1px solid var(--stroke);
  background: var(--panel);
  border-radius: 16px;
  padding: 10px;
  box-shadow: 0 12px 36px rgba(0,0,0,.10);
  display:flex;
  flex-direction:column;
  gap: 10px;
  overflow:hidden;
}
.selectRow{
  display:flex;
  gap: 12px;
  align-items:center;
  flex-wrap: wrap;
}
.selectLabel{
  font-weight: 1000;
  color: rgba(0,0,0,.86);
}
.noteButtons{
  display:grid;
  grid-template-columns: repeat(7, minmax(70px, 1fr));
  gap: 10px;
  flex: 1;
  width: 100%;
}
.noteBtn{
  /* ✅ Taller buttons (and now no wasted container space because input area is auto-sized) */
  height: 86px;
  border-radius: 16px;
  border: 2px solid rgba(0,0,0,.16);
  background: rgba(0,0,0,.05);
  color: white;
  font-weight: 1000;
  font-size: 28px;
  cursor:pointer;
  user-select:none;
  -webkit-user-select:none;
  touch-action: manipulation;
  box-shadow: 0 10px 26px rgba(0,0,0,.12);
}
.noteBtn:active{ transform: scale(.99); }
.noteBtn.selected{
  outline: 7px solid rgba(0,0,0,.28);
  outline-offset: 2px;
}

/* Buttons */
.actionRow{
  display:flex;
  gap: 10px;
  justify-content:center;
  flex-wrap: wrap;
}
.btn{
  border-radius: 16px;
  border: 2px solid rgba(0,0,0,.14);
  background: rgba(0,0,0,.05);
  color: rgba(0,0,0,.92);
  font-weight: 1000;
  font-size: 18px;
  padding: 14px 16px;
  cursor:pointer;
  user-select:none;
  -webkit-user-select:none;
  touch-action: manipulation;
  box-shadow: 0 12px 30px rgba(0,0,0,.10);
}
.btn:active{ transform: scale(.99); }
.btn.primary{
  background: rgba(0,135,255,.14);
  border-color: rgba(0,135,255,.35);
}
.btn.ghost{ background: rgba(0,0,0,.04); }

/* Overlays */
.overlay{
  position: fixed;
  inset: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,.30);

  opacity: 0;
  visibility: hidden;
  pointer-events: none;

  transition: opacity .16s ease;

  z-index: 50000;
}
.overlay.show{
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 60000;
}

.overlayCard{
  width: min(760px, 92%);
  border-radius: 18px;
  border: 1px solid rgba(0,0,0,.18);
  background: rgba(255,255,255,.98);
  box-shadow: 0 22px 70px rgba(0,0,0,.20);
  padding: 16px;
  text-align:center;
  pointer-events: auto;
}
.overlayCard.wide{
  width: min(1040px, 94%);
}

.overlayTitle{ font-size: 28px; font-weight: 1000; margin-bottom: 6px; color: rgba(0,0,0,.92); }
.overlayText{ font-size: 16px; color: rgba(0,0,0,.82); margin-bottom: 12px; }
.overlaySmall{ margin-top: 10px; color: rgba(0,0,0,.62); font-size: 12px; line-height: 1.35; }

.overlayButtons{
  display:flex;
  gap:10px;
  justify-content:center;
  flex-wrap:wrap;
  margin-top: 10px;
}

/* Team setup */
.teamGrid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
  text-align:left;
}
.teamField{
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,.14);
  background: rgba(0,0,0,.03);
  padding: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,.08);
}
.teamLabel{
  display:block;
  font-weight: 1000;
  font-size: 13px;
  color: rgba(0,0,0,.78);
  margin-bottom: 6px;
}
.teamInput{
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.18);
  background: rgba(255,255,255,.98);
  padding: 12px 12px;
  font-size: 16px;
  font-weight: 900;
  color: rgba(0,0,0,.92);
  outline: none;
}
.teamInput:focus{
  box-shadow: 0 0 0 4px rgba(0,135,255,.18);
  border-color: rgba(0,135,255,.40);
}

/* Tutorial */
.tutorialGrid{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  text-align:left;
  margin-top: 10px;
}
.tutorialPanel{
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,.14);
  background: rgba(0,0,0,.03);
  padding: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,.08);
}
.tutorialHeading{
  font-weight: 1000;
  font-size: 16px;
  margin-bottom: 6px;
  color: rgba(0,0,0,.92);
}
.tutorialList{
  margin: 0;
  padding-left: 18px;
  color: rgba(0,0,0,.82);
  font-weight: 800;
  line-height: 1.35;
}
.tutorialList li{ margin: 6px 0; }

/* Wrong overlay staff area */
.wrongStaffWrap{
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,.14);
  background: rgba(0,0,0,.03);
  padding: 10px;
  margin: 8px 0 6px;
}
.wrongStaffMount{
  width: 100%;
  height: 260px;
}

/* Wrong badges */
.wrongRow{
  display:flex;
  gap: 12px;
  justify-content:center;
  align-items:stretch;
  flex-wrap:wrap;
  margin: 6px 0 4px;
}
.wrongCol{ flex: 1; min-width: 240px; max-width: 420px; }
.wrongBadge{
  border-radius: 16px;
  border: 2px solid rgba(0,0,0,.14);
  background: rgba(0,0,0,.03);
  padding: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,.10);
}
.wrongBadge.bad{ border-color: rgba(255,29,37,.45); }
.wrongBadge.good{ border-color: rgba(122,201,67,.45); }

.wrongBadgeTop{
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 10px;
  margin-bottom: 6px;
}
.wrongSymbol{
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 22px;
  font-weight: 1000;
  color: white;
}
.wrongBadge.bad .wrongSymbol{ background: rgba(255,29,37,.95); }
.wrongBadge.good .wrongSymbol{ background: rgba(122,201,67,.95); }

.wrongBadgeLabel{
  font-weight: 1000;
  color: rgba(0,0,0,.78);
}
.wrongBadgeNote{
  font-size: 66px;
  font-weight: 1000;
  color: rgba(0,0,0,.92);
  line-height: 1;
  text-shadow: none;
}

/* Drip animation */
.dripLayer{
  position:absolute;
  inset:0;
  pointer-events:none;
  overflow:hidden;
}
.drip{
  position:absolute;
  top: 84px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #ff1d25;
  box-shadow: 0 0 0 6px rgba(255,29,37,.18);
  animation: dripFall 0.9s ease-in forwards;
}
.drip::after{
  content:"";
  position:absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -18px;
  width: 4px;
  height: 18px;
  border-radius: 999px;
  background: rgba(255,29,37,.85);
}
@keyframes dripFall{
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  80%  { transform: translateY(210px) scale(1.25); opacity: .95; }
  100% { transform: translateY(260px) scale(.6); opacity: 0; }
}

/* Leaderboard overlay list */
.boardList{
  display:flex;
  flex-direction:column;
  gap: 10px;
  margin-top: 10px;
  text-align:left;
}
.boardRow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,.14);
  background: rgba(0,0,0,.03);
  box-shadow: 0 12px 30px rgba(0,0,0,.08);
}
.boardName{
  font-weight: 1000;
  color: rgba(0,0,0,.92);
}
.boardScore{
  font-weight: 1000;
  font-size: 22px;
  color: rgba(0,0,0,.92);
}

@media (max-width: 980px){
  .tutorialGrid{ grid-template-columns: 1fr; }
  .teamGrid{ grid-template-columns: 1fr; }
}

@media (max-width: 820px){
  .noteButtons{ grid-template-columns: repeat(4, 1fr); }
  .slot{ width: 60px; height: 60px; font-size: 32px; }
  .wrongStaffMount{ height: 220px; }
  .wrongBadgeNote{ font-size: 56px; }
  .noteBtn{ height: 80px; font-size: 26px; }
}

@media (max-height: 680px){
  .noteBtn{ height: 66px; font-size: 24px; }
  .btn{ padding: 12px 14px; font-size: 16px; }
  .slot{ width: 58px; height: 58px; font-size: 30px; }
}
