*{
  box-sizing:border-box;
}

:root{
  --bg-dark:#0f380f;
  --bg-mid:#306230;
  --bg-light:#9bbc0f;
  --bg-panel:#8bac0f;
  --ink:#0f380f;
  --ink-soft:rgba(15,56,15,0.7);
  --line:rgba(15,56,15,0.18);

  --frame-base:#0f380f;
  --frame-accent:#306230;
  --frame-glow:rgba(155,188,15,0);
  --frame-rail:rgba(184,210,40,0);
  --frame-inner-shadow:rgba(15,56,15,0.12);
}

html,
body{
  margin:0;
  min-height:100%;
  background:#0f380f;
  font-family:monospace;
  color:#0f380f;
}

body{
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
  overflow-x:hidden;
}

.app-shell{
  width:100%;
  display:flex;
  align-items:center;
  justify-content:center;
}

.screen{
  width:100%;
  display:flex;
  align-items:center;
  justify-content:center;
}

.hidden{
  display:none !important;
}

/* =========================
   BOOT
========================= */

.boot-screen{
  position:fixed;
  inset:0;
  background:#9bbc0f;
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:center;
  color:#0f380f;
  z-index:999;
}

.boot-logo{
  font-size:42px;
  font-weight:bold;
  letter-spacing:6px;
  margin-bottom:20px;
}

.boot-sub{
  font-size:16px;
  margin-bottom:40px;
}

.boot-loading{
  font-size:14px;
  animation:blink 1s infinite;
}

.boot-hide{
  display:none;
}

@keyframes blink{
  0%{opacity:1;}
  50%{opacity:0.3;}
  100%{opacity:1;}
}

/* =========================
   MENU
========================= */

.menu-screen{
  position:fixed;
  inset:0;
  z-index:50;
  background:
    radial-gradient(circle at 20% 30%, rgba(155,188,15,0.12), transparent 30%),
    radial-gradient(circle at 80% 20%, rgba(184,210,40,0.1), transparent 26%),
    radial-gradient(circle at 50% 80%, rgba(48,98,48,0.18), transparent 30%),
    rgba(15,56,15,0.95);
  padding:20px;
}

.menu-card{
  width:100%;
  max-width:560px;
  background:#9bbc0f;
  border:8px solid #306230;
  box-shadow:
    0 0 0 2px rgba(15,56,15,0.08) inset,
    0 20px 50px rgba(0,0,0,0.28);
  padding:28px 22px;
  text-align:center;
}

.title-kicker{
  font-size:12px;
  letter-spacing:2px;
  margin-bottom:12px;
  opacity:0.8;
  text-transform:uppercase;
}

.title-main{
  margin:0 0 16px 0;
  font-size:36px;
  letter-spacing:3px;
}

.title-copy{
  font-size:14px;
  line-height:1.6;
  margin:0 0 12px 0;
}

.title-note{
  font-size:13px;
  line-height:1.5;
  margin:0 0 20px 0;
  padding:10px 12px;
  background:rgba(15,56,15,0.08);
  border:1px solid rgba(15,56,15,0.16);
}

.menu-actions{
  display:flex;
  flex-direction:column;
  gap:12px;
}

/* =========================
   PANELS
========================= */

.game-container,
.sequencer-container{
  background:#9bbc0f;
  padding:18px;
  border:8px solid #306230;
  width:920px;
  max-width:100%;
  box-shadow:
    0 0 0 2px rgba(15,56,15,0.08) inset,
    0 18px 42px rgba(0,0,0,0.22);
}

.game-container{
  width:470px;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:12px;
}

.brand-lockup h2{
  margin:0;
  letter-spacing:2px;
  font-size:26px;
}

.brand-small{
  font-size:11px;
  letter-spacing:2px;
  opacity:0.7;
  margin-bottom:2px;
}

.topbar-actions{
  display:flex;
  gap:8px;
}

.scoreboard{
  margin-bottom:10px;
  color:#0f380f;
  font-weight:bold;
  font-size:14px;
  line-height:1.5;
}

.seq-topbar{
  margin-bottom:14px;
}

.seq-status-chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:8px 12px;
  border:1px solid rgba(15,56,15,0.16);
  background:rgba(15,56,15,0.06);
  font-size:13px;
  font-weight:bold;
  min-height:38px;
}

/* =========================
   BUTTONS
========================= */

button{
  font-size:18px;
  padding:10px 16px;
  background:#306230;
  border:none;
  color:#9bbc0f;
  cursor:pointer;
  font-family:inherit;
  box-shadow:inset 0 0 0 1px rgba(155,188,15,0.05);
  transition:transform 120ms ease, filter 120ms ease, background 120ms ease, box-shadow 140ms ease;
  touch-action:manipulation;
}

button:hover{
  filter:brightness(1.06);
}

button:active{
  transform:translateY(1px);
}

.title-button{
  font-size:17px;
  padding:14px 18px;
}

.title-button.alt,
.secondary-button{
  background:#1f4d1f;
}

.small-button{
  min-width:56px;
  padding:8px 12px;
  font-size:15px;
}

/* =========================
   GAME VIEW
========================= */

.sequencer-preview{
  width:400px;
  max-width:100%;
  margin:0 auto 12px auto;
  min-height:58px;
  display:grid;
  grid-template-columns:repeat(16, 1fr);
  grid-auto-rows:27px;
  gap:4px;
  align-content:start;
}

.seq-step{
  width:100%;
  height:27px;
  background:#8bac0f;
  border:1px solid rgba(15,56,15,0.22);
  display:flex;
  align-items:center;
  justify-content:center;
  position:relative;
  overflow:hidden;
  transition:transform 0.08s ease, opacity 0.18s ease, background 0.18s ease, filter 0.18s ease, border-color 0.18s ease;
}

.seq-step::after{
  content:"";
  position:absolute;
  inset:0;
  background:linear-gradient(to bottom, rgba(255,255,255,0.04), rgba(255,255,255,0));
  pointer-events:none;
}

.seq-step.filled{
  opacity:1;
}

.seq-step.filled.variant-base{
  background:#306230;
  border-color:rgba(15,56,15,0.30);
}

.seq-step.filled.variant-alt{
  background:#487f1e;
  border-color:rgba(15,56,15,0.24);
  box-shadow:inset 0 0 0 1px rgba(200,235,90,0.08);
}

.seq-step.active-empty{
  background:#8bac0f;
  opacity:0.9;
}

.seq-step.future{
  opacity:0.28;
}

.seq-step.current{
  outline:1px solid #0f380f;
  outline-offset:1px;
  transform:translateY(-1px);
  box-shadow:inset 0 0 0 1px rgba(184,210,40,0.18);
}

.seq-step-label{
  font-size:9px;
  line-height:1;
  color:rgba(15,56,15,0.34);
  letter-spacing:0.2px;
  text-transform:uppercase;
  pointer-events:none;
}

.seq-step.filled .seq-step-label{
  color:rgba(155,188,15,0.92);
}

.seq-step.filled.variant-alt .seq-step-label{
  color:rgba(232,247,164,0.95);
}

.seq-step.active-empty .seq-step-label{
  color:rgba(15,56,15,0.42);
}

.seq-step.current .seq-step-label{
  color:#9bbc0f;
}

.playfield{
  position:relative;
  width:400px;
  height:400px;
  margin:0 auto;
  overflow:hidden;
  touch-action:none;
  background:
    linear-gradient(to bottom, rgba(184,210,40,0.018), rgba(15,56,15,0.02)),
    #87a80f;
  border:4px solid var(--frame-base);
  box-shadow:
    0 0 0 1px var(--frame-accent),
    0 0 0 2px var(--frame-inner-shadow) inset,
    0 0 12px var(--frame-glow),
    inset 0 0 8px rgba(184,210,40,0.02);
  transition:
    border-color 90ms linear,
    box-shadow 90ms linear,
    background 180ms linear,
    filter 120ms linear,
    opacity 120ms linear;
}

.playfield::before{
  content:"";
  position:absolute;
  inset:8px;
  pointer-events:none;
  border:1px solid rgba(184,210,40,0.04);
  box-shadow:
    inset 0 0 0 1px rgba(15,56,15,0.05),
    0 0 8px var(--frame-rail);
  opacity:1;
  z-index:3;
}

.playfield::after{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  background:
    linear-gradient(to right, var(--frame-rail), transparent 18%, transparent 82%, var(--frame-rail)),
    linear-gradient(to bottom, var(--frame-rail), transparent 18%, transparent 82%, var(--frame-rail));
  opacity:0.34;
  mix-blend-mode:screen;
  z-index:3;
}

.playfield.paused{
  filter:brightness(0.72) saturate(0.88);
}

.playfield.round-transition{
  filter:brightness(1.12) saturate(1.22);
}

.playfield.death-impact{
  animation:deathImpactShake 260ms linear 1;
}

#bgCanvas,
#game{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  display:block;
}

#bgCanvas{
  z-index:0;
  opacity:0;
  transition:opacity 320ms ease;
}

.playfield-veil{
  position:absolute;
  inset:0;
  z-index:1;
  pointer-events:none;
  background:
    radial-gradient(circle at center, rgba(255,255,255,0.00) 0%, rgba(255,255,255,0.02) 48%, rgba(15,56,15,0.09) 100%),
    linear-gradient(to bottom, rgba(15,56,15,0.02), rgba(15,56,15,0.12));
}

#game{
  z-index:2;
  background:transparent;
  border:none;
  image-rendering:pixelated;
  transition:background 180ms linear, filter 180ms linear;
}

.pause-overlay{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(15,56,15,0.24);
  z-index:5;
  pointer-events:none;
  opacity:0;
  transition:opacity 120ms linear;
}

.pause-overlay.visible{
  opacity:1;
}

.pause-card{
  padding:12px 18px;
  border:2px solid #306230;
  background:rgba(15,27,15,0.92);
  color:#9bbc0f;
  font-size:22px;
  font-weight:bold;
  letter-spacing:2px;
  text-transform:uppercase;
  box-shadow:
    0 0 0 1px rgba(184,210,40,0.08) inset,
    0 0 18px rgba(184,210,40,0.08);
}

.round-flash{
  position:absolute;
  inset:0;
  z-index:6;
  pointer-events:none;
  opacity:0;
  background:
    radial-gradient(circle at centre,
    rgba(252,255,244,0.92) 0%,
    rgba(236,242,212,0.56) 38%,
    rgba(220,228,182,0.18) 66%,
    rgba(220,228,182,0) 100%);
}

.round-flash.visible{
  animation:roundFlash 420ms ease forwards;
}

.death-fade{
  position:absolute;
  inset:0;
  z-index:7;
  pointer-events:none;
  opacity:0;
  background:
    radial-gradient(circle at centre, rgba(112,35,40,0.18), rgba(58,11,17,0.38) 36%, rgba(12,5,6,0.88) 100%);
}

.death-fade.self-impact{
  background:
    radial-gradient(circle at centre, rgba(145,44,52,0.24), rgba(76,14,20,0.52) 34%, rgba(5,5,6,0.94) 100%);
}

.death-fade.wall-impact{
  background:
    radial-gradient(circle at centre, rgba(85,95,70,0.16), rgba(22,24,18,0.34) 38%, rgba(5,5,6,0.94) 100%);
}

.death-fade.visible{
  animation:deathFadeIn 900ms ease forwards;
}

.controls{
  margin-top:15px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:8px;
}

.middle{
  display:flex;
  gap:10px;
}

#pause{
  min-width:52px;
  width:52px;
  height:52px;
  padding:0;
  font-size:18px;
  line-height:1;
  display:flex;
  align-items:center;
  justify-content:center;
}

.overlay{
  position:absolute;
  inset:0;
  background:rgba(0,0,0,0.76);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
  z-index:8;
}

.overlay-card{
  width:100%;
  max-width:340px;
  max-height:100%;
  background:#0f1b0f;
  border:2px solid #306230;
  box-shadow:0 0 0 2px rgba(155,188,15,0.08) inset;
  color:#9bbc0f;
  padding:18px 16px 14px 16px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:12px;
}

.overlay h2{
  margin:0;
  font-size:24px;
  line-height:1;
  letter-spacing:1px;
  color:#9bbc0f;
}

.sequence-panel{
  width:100%;
  flex:1 1 auto;
  min-height:0;
  background:rgba(155,188,15,0.04);
  border:1px solid rgba(155,188,15,0.16);
  padding:10px;
  text-align:left;
  overflow:hidden;
}

.sequence-panel-title{
  font-size:12px;
  letter-spacing:1px;
  margin-bottom:8px;
  opacity:0.85;
}

.gameover-sequence{
  display:grid;
  grid-template-columns:repeat(4, 1fr);
  gap:6px;
  height:100%;
  max-height:248px;
  overflow:auto;
  padding-right:4px;
}

.gameover-note{
  min-height:30px;
  padding:5px 6px;
  border:1px solid rgba(155,188,15,0.14);
  background:rgba(155,188,15,0.04);
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:flex-start;
  opacity:0;
  transform:translateY(7px);
  animation:gameoverNoteIn 240ms ease forwards;
}

.gameover-note.variant-base{
  background:rgba(48,98,48,0.18);
  border-color:rgba(48,98,48,0.40);
}

.gameover-note.variant-alt{
  background:rgba(72,127,30,0.20);
  border-color:rgba(184,210,40,0.26);
}

.gameover-note.empty{
  opacity:0.42;
}

.gameover-step{
  font-size:9px;
  opacity:0.65;
  margin-bottom:2px;
}

.gameover-name{
  font-size:12px;
  font-weight:bold;
  letter-spacing:0.4px;
  line-height:1.1;
}

.overlay-actions{
  width:100%;
  display:flex;
  justify-content:center;
  gap:8px;
  flex-wrap:wrap;
}

/* =========================
   SEQUENCER MODE
========================= */

.sequencer-toolbar{
  display:flex;
  flex-wrap:wrap;
  gap:12px;
  margin-bottom:14px;
  align-items:flex-end;
  justify-content:space-between;
}

.toolbar-group{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
}

.slider-wrap{
  display:flex;
  flex-direction:column;
  gap:4px;
  min-width:180px;
}

.slider-wrap.wide{
  min-width:260px;
}

.slider-wrap label{
  font-size:11px;
  letter-spacing:1px;
  text-transform:uppercase;
  opacity:0.75;
}

.readout{
  font-size:14px;
  font-weight:bold;
  min-width:74px;
  text-align:center;
}

input[type="range"]{
  width:100%;
  accent-color:#306230;
  touch-action:pan-y;
}

.sequencer-board{
  border:2px solid rgba(15,56,15,0.18);
  background:rgba(15,56,15,0.05);
  padding:10px;
}

.sequencer-header{
  display:grid;
  grid-template-columns:110px 1fr;
  gap:8px;
  align-items:center;
  margin-bottom:10px;
}

.header-left{
  font-size:11px;
  letter-spacing:1px;
  text-transform:uppercase;
  opacity:0.75;
}

.step-numbers{
  display:grid;
  grid-template-columns:repeat(16, minmax(0, 1fr));
  gap:4px;
}

.step-number{
  height:22px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:10px;
  font-weight:bold;
  border:1px solid rgba(15,56,15,0.14);
  background:rgba(15,56,15,0.05);
  transition:background 120ms ease, color 120ms ease, transform 120ms ease;
}

.step-number.current{
  background:#306230;
  color:#9bbc0f;
  transform:translateY(-1px);
}

.sequencer-section{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.section-title{
  font-size:12px;
  letter-spacing:2px;
  text-transform:uppercase;
  font-weight:bold;
}

.notes-title{
  color:#143d14;
}

.drums-title{
  color:#1f4d1f;
}

.sequencer-divider{
  height:1px;
  background:rgba(15,56,15,0.16);
  margin:14px 0;
}

.grid-rows{
  display:flex;
  flex-direction:column;
  gap:4px;
}

.grid-row{
  display:grid;
  grid-template-columns:110px 1fr;
  gap:8px;
  align-items:center;
}

.row-label{
  min-height:24px;
  display:flex;
  align-items:center;
  padding:0 8px;
  border:1px solid rgba(15,56,15,0.16);
  background:rgba(15,56,15,0.05);
  font-size:12px;
  font-weight:bold;
}

.row-steps{
  display:grid;
  grid-template-columns:repeat(16, minmax(0, 1fr));
  gap:4px;
}

.cell{
  --cell-on:#306230;
  height:24px;
  min-height:24px;
  border:1px solid rgba(15,56,15,0.18);
  background:#8bac0f;
  cursor:pointer;
  transition:transform 80ms ease, filter 120ms ease, background 120ms ease, box-shadow 120ms ease, outline 120ms ease, border-color 120ms ease;
  position:relative;
  padding:0;
  border-radius:0;
  -webkit-tap-highlight-color:transparent;
  user-select:none;
  touch-action:none;
}

.cell:hover{
  filter:brightness(1.04);
}

.cell:active{
  transform:translateY(1px);
}

.cell.on{
  background:var(--cell-on);
  border-color:rgba(15,56,15,0.34);
  box-shadow:inset 0 0 0 1px rgba(15,56,15,0.16);
}

.cell.current{
  outline:1px solid #0f380f;
  outline-offset:1px;
}

.cell.note-cell.on::after,
.cell.drum-cell.on::after{
  content:none;
}

/* =========================
   CONFIRM MODAL
========================= */

.confirm-overlay{
  position:fixed;
  inset:0;
  z-index:200;
  background:rgba(3,10,3,0.74);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
  animation:fadeInSoft 160ms ease;
}

.confirm-card{
  width:100%;
  max-width:360px;
  background:#0f1b0f;
  border:2px solid #306230;
  box-shadow:
    0 0 0 2px rgba(155,188,15,0.06) inset,
    0 16px 36px rgba(0,0,0,0.34);
  color:#9bbc0f;
  padding:18px 16px 14px;
  transform:translateY(0);
  animation:confirmLift 180ms ease;
}

.confirm-card h3{
  margin:0 0 10px 0;
  font-size:22px;
  letter-spacing:1px;
}

.confirm-card p{
  margin:0;
  font-size:14px;
  line-height:1.55;
  color:rgba(155,188,15,0.88);
}

.confirm-actions{
  margin-top:16px;
  display:flex;
  justify-content:flex-end;
  gap:8px;
  flex-wrap:wrap;
}

/* =========================
   ANIMATION
========================= */

@keyframes roundFlash{
  0%{ opacity:0; }
  18%{ opacity:1; }
  100%{ opacity:0; }
}

@keyframes deathFadeIn{
  0%{ opacity:0; }
  100%{ opacity:1; }
}

@keyframes gameoverNoteIn{
  0%{
    opacity:0;
    transform:translateY(7px);
  }
  100%{
    opacity:1;
    transform:translateY(0);
  }
}

@keyframes deathImpactShake{
  0%{ transform:translate(0, 0); }
  20%{ transform:translate(-2px, 1px); }
  40%{ transform:translate(2px, -1px); }
  60%{ transform:translate(-1px, 2px); }
  80%{ transform:translate(2px, 1px); }
  100%{ transform:translate(0, 0); }
}

@keyframes fadeInSoft{
  from{ opacity:0; }
  to{ opacity:1; }
}

@keyframes confirmLift{
  from{
    opacity:0;
    transform:translateY(8px);
  }
  to{
    opacity:1;
    transform:translateY(0);
  }
}

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

@media (max-width: 980px){
  .sequencer-container{
    width:100%;
  }
}

@media (max-width: 620px){
  body{
    padding:10px;
  }

  .game-container,
  .sequencer-container{
    width:100%;
    padding:14px;
  }

  .playfield,
  .sequencer-preview{
    width:100%;
  }

  .playfield{
    height:auto;
    aspect-ratio:1 / 1;
  }

  .sequencer-header,
  .grid-row{
    grid-template-columns:88px 1fr;
  }

  .row-label{
    font-size:11px;
    padding:0 6px;
  }

  .step-number{
    height:20px;
  }

  .cell{
    height:22px;
    min-height:22px;
  }

  .brand-lockup h2{
    font-size:22px;
  }

  .title-main{
    font-size:30px;
  }

  .topbar{
    align-items:flex-start;
    flex-direction:column;
  }

  .sequencer-toolbar{
    align-items:stretch;
  }
}

