* { box-sizing: border-box; margin: 0; padding: 0; }
:root { --bg: #05060f; }
html, body {
  height: 100%;
  background: #02030a;
  color: #eaf6ff;
  font-family: "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px;
}
#stage {
  position: relative;
  width: min(94vw, 46vh);
  aspect-ratio: 9 / 16;
}
#game {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 14px;
  background: #05060f;
  touch-action: none;
}

/* Overlays */
.overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; padding: 24px;
  background: rgba(4,6,18,0.86);
  backdrop-filter: blur(3px);
  border-radius: 14px;
  text-align: center;
}
#screen-title {
  background: rgba(4,6,18,0.42);
  backdrop-filter: blur(2px);
}
.overlay.hidden { display: none; }
.logo { font-size: 34px; letter-spacing: 6px; }
.logo .c { color:#00E5FF; text-shadow:0 0 12px #00E5FF; }
.logo .m { color:#FF2D95; text-shadow:0 0 12px #FF2D95; }
.logo .y { color:#FFE600; text-shadow:0 0 12px #FFE600; }
.logo .g { color:#39FF14; text-shadow:0 0 12px #39FF14; }
.title-word {
  font-weight: 800; font-size: 22px; letter-spacing: 4px;
  color:#fff; text-shadow:0 0 10px #7bdfff, 0 0 20px #4aa8ff;
}
h2 { font-size: 20px; letter-spacing: 2px; text-shadow:0 0 10px #4aa8ff; }
.menu { display:flex; flex-direction:column; gap:10px; width: 74%; }
.btn {
  font: inherit; font-weight: 700; letter-spacing: 1px;
  color:#eaf6ff; padding: 11px 14px; border-radius: 12px;
  background: linear-gradient(180deg, rgba(30,40,80,.7), rgba(12,16,40,.7));
  border: 2px solid #2fd2ff;
  box-shadow: 0 0 10px rgba(47,210,255,.5), inset 0 0 8px rgba(47,210,255,.25);
  cursor: pointer; transition: transform .06s, box-shadow .15s;
}
.btn:hover { box-shadow: 0 0 16px rgba(47,210,255,.8), inset 0 0 10px rgba(47,210,255,.4); }
.btn:active { transform: scale(.97); }
.tagline {
  font-size: 12px; letter-spacing: 2px; color: #8ab4d8;
  margin-top: -8px; margin-bottom: 4px;
}
.hiscore { font-size: 13px; color:#9fe0ff; letter-spacing:2px; }
.title-footer {
  position: absolute; left: 0; right: 0; bottom: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.lang-bar {
  display: flex; justify-content: center; gap: 12px;
}
.lang-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 46px; height: 32px; padding: 0; border-radius: 8px; cursor: pointer;
  background: rgba(10,16,40,.55);
  border: 2px solid rgba(47,210,255,.35);
  box-shadow: none; opacity: .55;
  transition: opacity .15s, box-shadow .15s, border-color .15s, transform .06s;
}
.lang-btn .flag {
  width: 30px; height: 20px; display: block;
  object-fit: cover; border-radius: 2px;
  pointer-events: none;
}
.lang-btn:hover { opacity: .9; }
.lang-btn:active { transform: scale(.96); }
.lang-btn.active {
  opacity: 1;
  border-color: #2fd2ff;
  box-shadow: 0 0 12px rgba(47,210,255,.55);
}
.credit { font-size:11px; color:#5a6a90; letter-spacing:2px; }

/* HOW TO — fill same stage as game, balanced title / body / close gaps */
#screen-howto {
  justify-content: flex-start;
  align-items: stretch;
  gap: 20px;
  padding: 18px 12px 16px;
  text-align: left;
}
#screen-howto h2 {
  flex-shrink: 0;
  text-align: center;
  font-size: 18px;
  margin: 0;
  padding-bottom: 2px;
}
#screen-howto .btn {
  flex-shrink: 0;
  align-self: center;
  width: 74%;
  margin-top: 0;
}
.howto-list {
  flex: 0 1 auto;
  min-height: 0;
  width: 100%;
  max-width: none;
  max-height: calc(100% - 118px);
  overflow-y: auto;
  overflow-x: hidden;
  text-align: left;
  font-size: 13.5px;
  line-height: 1.45;
  color: #cfe8ff;
  padding: 0 2px 0 1.1em;
  list-style-position: outside;
  scrollbar-width: thin;
  scrollbar-color: rgba(47,210,255,.45) transparent;
}
.howto-list::-webkit-scrollbar { width: 4px; }
.howto-list::-webkit-scrollbar-thumb {
  background: rgba(47,210,255,.45); border-radius: 4px;
}
.howto-list b { color:#7bffce; }
.howto-list li { margin-bottom: 8px; }
.howto-tile {
  display: inline-block; vertical-align: middle;
  width: 26px; height: 26px;
  margin: 0; border-radius: 4px;
}
.howto-icons {
  display: inline-flex; align-items: center; gap: 2px;
  vertical-align: middle; margin: 0 2px;
}
.howto-mulwrap {
  display: inline-flex; align-items: center; gap: 2px;
  vertical-align: middle; margin: 0 2px;
}
.howto-garbage {
  display: inline-flex; align-items: center; gap: 2px;
  vertical-align: middle; margin: 0 2px;
}
.howto-piece {
  display: inline-flex; flex-direction: column-reverse; gap: 1px;
  vertical-align: middle; margin: 0 3px;
}
.howto-piece .howto-tile { width: 20px; height: 20px; }
.howto-mul {
  font-weight: 800; font-size: 13px; letter-spacing: 0.5px;
  color: #9fe0ff;
}
.howto-controls {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 4px; width: 100%;
}
.howto-ctrl-block {
  display: flex; flex-direction: column; gap: 3px;
  padding: 6px 8px;
  background: rgba(12,18,40,.55);
  border: 1px solid rgba(47,210,255,.25);
  border-radius: 8px;
}
.howto-ctrl-title {
  font-size: 12px; font-weight: 800; letter-spacing: 1px;
  color: #7bffce; margin-bottom: 1px;
}
.howto-ctrl-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; min-height: 26px;
}
.howto-ctrl-label {
  color: #cfe8ff; font-size: 12.5px; flex: 1;
}
.howto-keygroup { display: inline-flex; align-items: center; gap: 3px; flex-shrink: 0; }
.howto-key {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 24px; padding: 0 6px;
  font: 700 12px/1 "Segoe UI", system-ui, sans-serif;
  color: #eaf6ff;
  background: linear-gradient(180deg, #334066, #141a30);
  border: 1px solid #4aa8ff;
  border-bottom-width: 3px;
  border-radius: 5px;
  box-shadow: 0 0 8px rgba(47,210,255,.35);
}
.howto-key.wide {
  min-width: 48px; font-size: 10px; letter-spacing: 0.4px;
}
.result { font-size:16px; line-height:1.9; letter-spacing:1px; }
.result .val { color:#7bffce; font-weight:800; }
.sound-opts {
  display: flex; flex-direction: column; gap: 14px;
  width: 82%;
}
.opt {
  display: flex; align-items: center; gap: 12px;
  font-size: 14px; font-weight: 700; letter-spacing: 1px;
  color: #9fe0ff;
}
.opt span { min-width: 40px; text-align: left; }
.opt input { flex: 1; min-width: 0; }

/* Mobile controls */
#controls {
  display: none;
  width: min(94vw, 46vh);
  gap: 10px;
  grid-template-columns: 1fr 1fr 1fr 1fr;
}
#controls.show { display: grid; }
.pad {
  display: flex; align-items: center; justify-content: center;
  padding: 12px 0; border-radius: 14px;
  background: rgba(10,16,40,.8);
  border: 2px solid #2fd2ff;
  box-shadow: 0 0 10px rgba(47,210,255,.45);
  color: #7BEAFF;
  cursor: pointer;
}
.pad-ico {
  width: 52%;
  max-width: 34px;
  aspect-ratio: 1;
  height: auto;
  pointer-events: none;
  display: block;
  overflow: visible;
  filter: drop-shadow(0 0 4px rgba(123,234,255,.55));
}
.pad:active { transform: scale(.96); background: rgba(20,30,70,.9); }
.pad.drop {
  border-color:#ff4fa3;
  box-shadow:0 0 10px rgba(255,79,163,.6);
  color: #FF6EC7;
}
.pad.drop .pad-ico {
  filter: drop-shadow(0 0 4px rgba(255,110,199,.65));
}
.pad.reserved { opacity:.28; border-style:dashed; }
