:root {
  --bg-primary: #000000;  /* pure black = transparent on additive display */
  --surface: #0b0e12;
  --surface-2: #121820;
  --line: #232d3a;
  --text-primary: #f2f6f8;
  --text-secondary: #8fa1b3;
  --blade: #00ff88;       /* the cutter color — main accent */
  --blade-dim: #0a4d31;
  --amber: #ffb830;       /* ball color */
  --danger: #ff3d7f;
  --cut: 14px;            /* corner cut size */
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'SF Mono', 'Menlo', 'Consolas', 'Roboto Mono', monospace;
  background: var(--bg-primary);
  color: var(--text-primary);
  width: 600px;
  height: 600px;
  overflow: hidden;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
}

/* --- Screens --- */
.screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 0;
  padding: 8px; /* safe margin */
}
.screen.hidden { display: none; }

/* --- Cut-corner helper (the visual motif: everything is sliced) --- */
.cutbox {
  clip-path: polygon(
    var(--cut) 0, 100% 0,
    100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%,
    0 100%, 0 var(--cut)
  );
}

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 2px solid var(--line);
  gap: 12px;
  flex-shrink: 0;
  clip-path: polygon(var(--cut) 0, 100% 0, 100% 100%, 0 100%, 0 var(--cut));
}
.header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 4px;
  text-transform: uppercase;
  flex: 1;
}
.header-meta {
  font-size: 15px;
  color: var(--blade);
  letter-spacing: 1px;
}

/* --- Home --- */
.home-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  padding: 8px 12px;
}
.hero { text-align: center; position: relative; padding: 12px 0; }
.hero-title {
  font-size: 68px;
  font-weight: 800;
  letter-spacing: 18px;
  text-indent: 18px; /* balance the trailing letter-spacing */
  color: var(--text-primary);
  position: relative;
  display: inline-block;
  line-height: 1;
}
/* the title is literally sliced: top half shifted left, bottom half right */
.hero-title .half {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  color: var(--text-primary);
}
.hero-title .half.top {
  clip-path: polygon(0 0, 100% 0, 100% 38%, 0 58%);
  transform: translate(-5px, -3px);
}
.hero-title .half.bottom {
  clip-path: polygon(0 58%, 100% 38%, 100% 100%, 0 100%);
  transform: translate(5px, 3px);
  color: var(--blade);
}
.hero-title .base { visibility: hidden; }
.hero-cutline {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 50%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--blade) 15%, var(--blade) 85%, transparent);
}
.hero-sub {
  font-size: 15px;
  color: var(--text-secondary);
  margin-top: 20px;
  letter-spacing: 3px;
  text-transform: uppercase;
}

/* --- How-to card --- */
.howto {
  background: var(--surface);
  border-left: 3px solid var(--blade);
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%);
}
.howto-row {
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-primary);
}
.howto-key {
  min-width: 84px;
  text-align: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 7px 8px;
  color: var(--amber);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1px;
  flex-shrink: 0;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}

/* --- Focus States (D-pad) : hard blade edge, no glow --- */
.focusable {
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer;
  min-height: 44px;
  position: relative;
}
.focusable:focus {
  outline: none;
  border-color: var(--blade);
}
.focusable:focus::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 50%;
  width: 10px;
  height: 2px;
  background: var(--blade);
}
.focusable:focus::after {
  content: '';
  position: absolute;
  right: 10px;
  top: 50%;
  width: 10px;
  height: 2px;
  background: var(--blade);
}

/* --- Navigation Bar --- */
.nav-bar {
  display: flex;
  gap: 8px;
  padding: 12px 0 4px;
  flex-shrink: 0;
}
.nav-item {
  flex: 1;
  padding: 20px 16px;
  background: var(--surface-2);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  text-align: center;
  clip-path: polygon(
    var(--cut) 0, 100% 0,
    100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%,
    0 100%, 0 var(--cut)
  );
}
.nav-item:focus {
  background: var(--blade-dim);
  color: var(--blade);
}
.nav-item.primary {
  background: var(--blade);
  color: #04140c;
}
.nav-item.primary:focus {
  background: #04140c;
  color: var(--blade);
  border-color: var(--blade);
}

/* --- Game HUD --- */
.game-hud {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 2px solid var(--line);
  flex-shrink: 0;
  margin-bottom: 8px;
  clip-path: polygon(var(--cut) 0, 100% 0, 100% 100%, 0 100%, 0 var(--cut));
}
.hud-item {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-primary);
  flex-shrink: 0;
}
#hud-lives { color: var(--danger); letter-spacing: 4px; font-size: 15px; }
#hud-lives.flash { animation: hudflash 0.6s ease; }
@keyframes hudflash {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.5); }
}
.hud-progress {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}
.hud-pct {
  font-size: 15px;
  font-weight: 700;
  color: var(--blade);
  min-width: 44px;
  text-align: right;
}
.progress-bar {
  flex: 1;
  height: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  clip-path: polygon(4px 0, 100% 0, 100% calc(100% - 4px), calc(100% - 4px) 100%, 0 100%, 0 4px);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: repeating-linear-gradient(
    -45deg,
    var(--blade) 0, var(--blade) 8px,
    #00cc6d 8px, #00cc6d 16px
  );
  transition: width 0.3s ease;
}

/* --- Game Canvas --- */
.canvas-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
#game-canvas {
  background: #05070a;
  border: 1px solid var(--line);
}

/* --- Overlay (level clear / game over) --- */
.game-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(4, 6, 9, 0.88);
}
.game-overlay.hidden { display: none; }
.overlay-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: var(--blade);
  border-top: 2px solid var(--blade);
  border-bottom: 2px solid var(--blade);
  padding: 10px 26px;
}
.overlay-sub {
  font-size: 15px;
  color: var(--text-secondary);
  letter-spacing: 1px;
  margin-bottom: 10px;
}
.game-overlay .nav-item {
  flex: none;
  min-width: 280px;
}

/* --- Utility --- */
.hidden { display: none !important; }
