:root {
  --bg: #0b1020;
  --panel: #121933;
  --text: #e9ecf1;
  --muted: #b7c0d3;
  --accent: #5b8cff;
  --good: #3ddc97;
  --bad: #ff5b6e;
  --border: #223055;
}
* { box-sizing: border-box }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Noto Sans, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}
.topbar { display:flex; align-items:center; justify-content:space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); background: #0b1126; }
.topbar h1 { margin:0; font-size: 18px; }
.brand { display: inline-flex; align-items: center; gap: 6px; }
.brand-logo {
  width: 24px;
  height: 24px;
  display: block;
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(91, 140, 255, 0.25);
}
#pageTitleText {
  font-weight: 900;
  letter-spacing: 1px;
  display: inline-flex;
  gap: 4px;
}
.title-shape {
  background: linear-gradient(90deg, #9aa8ff, #8affc1, #ffd93d, #ff9fb1);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 4s ease-in-out infinite;
  text-shadow: none;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.6));
}
.title-drop {
  color: #ffffff;
  opacity: 0.92;
  text-shadow: 0 2px 6px rgba(91, 140, 255, 0.4), 0 0 2px rgba(255,255,255,0.15);
  animation: dropPulse 2.5s ease-in-out infinite;
}
@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
@keyframes dropPulse {
  0%, 100% { opacity: 0.92; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(1px); }
}
.top-actions { display: flex; align-items: center; gap: 8px; }
.btn, button { display:inline-block; background:#1a2447; color:#fff; padding:8px 12px; border:1px solid var(--border); border-radius:8px; text-decoration:none; cursor:pointer; }
button.primary { background: var(--accent); border-color:#3e68d1; }

.wrap { display:grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 12px; align-items: start; max-width: 1260px; margin: 0 auto; padding: 12px; }
.hud-row { grid-column: 1 / 2; display: flex; justify-content: center; }
.left { grid-column: 1 / 2; grid-row: 2; position:relative; display:flex; flex-direction:column; align-items:center; justify-content:flex-start; padding: 0; gap: 6px; }
.side-panel { grid-column: 2 / 3; grid-row: 2; align-self: start; width: 280px; padding: 12px; background: #0c1430; border: 1px solid var(--border); border-radius: 10px; }
.canvas-wrap { width: 100%; max-width: 960px; margin: 0; }
.side-panel h2 { margin-top:0; }
.side-panel .controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.side-panel .controls select { width: 100%; max-width: 200px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); background: #0a0f22; color: var(--text); }
.side-panel label.small { color: var(--muted); }
.mode-row { grid-column: 1 / -1; }
.mode-row label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mode-note { grid-column: 1 / -1; font-size: 12px; color: #9fb0db; margin-top: -2px; }
.level-sound-row { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.inline-sound { white-space: nowrap; font-size: 12px; }
.usage-wrap { grid-column: 1 / -1; position: relative; overflow: visible; }
.usage-toggle { width: 100%; background: #152144; border: 1px solid #2b3f7b; font-size: 12px; padding: 7px 9px; }
.usage { margin-top: 6px; max-height: 0; opacity: 0; overflow: hidden; padding: 0 10px; border: 1px solid transparent; border-radius: 8px; background: rgba(11, 17, 38, 0.92); font-size: 12px; line-height: 1.5; color: #cdd4e8; transition: max-height 0.32s ease, opacity 0.22s ease, padding 0.22s ease, border-color 0.22s ease; }
body.usage-open .usage { max-height: 480px; opacity: 1; padding: 10px 12px; border-color: var(--border); }
.usage strong { display: block; margin-bottom: 6px; color: #fff; font-size: 13px; letter-spacing: 0.5px; border-bottom: 1px solid #1e2e5a; padding-bottom: 5px; }
.usage-section { margin-top: 8px; }
.usage-section:first-of-type { margin-top: 4px; }
.usage-heading { display: block; font-weight: 700; font-size: 12px; color: #8aabff; margin-bottom: 2px; }
.usage p { margin: 1px 0; padding-left: 10px; color: #c0c8de; }
.note { color: var(--muted); }

canvas#game {
  display: block;
  width: 100%;
  height: auto;
  background: #0a0f22;
  border: 1px solid var(--border);
  border-radius: 10px;
  touch-action: none;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255,255,255,0.04);
}
.hidden { display: none !important; }

.hud { position:static; width: 100%; max-width: 960px; display:flex; flex-direction:column; align-items:center; gap: 8px; margin-bottom: 2px; }
.status { display:flex; flex-wrap: wrap; gap: 8px 12px; justify-content: center; align-items: center; background: rgba(0,0,0,0.35); padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); }
.status-main { font-size: 15px; background: rgba(7, 13, 31, 0.78); }
.status-main strong { font-size: 22px; color: #fff; margin-left: 2px; }
.status-secondary { opacity: 0.95; font-size: 13px; }
.status-secondary strong { font-size: 14px; }
.rule-inline { opacity: 0.92; color: #d6def7; white-space: nowrap; }
.message { font-weight: 700; text-shadow: 0 2px 8px rgba(0,0,0,0.6); }

/* Modal */
.modal { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; background: rgba(0,0,0,0.45); }
.modal-card { background:#0c1430; border:1px solid var(--border); border-radius:12px; padding:16px; width: min(420px, 92%); box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
.modal-card h3 { margin: 0 0 8px; }
.modal-actions { display:flex; gap:8px; justify-content:flex-end; margin-top:12px; }

/* Mobile bottom toolbar */
/* mobile toolbar/preview removed */

@media (prefers-reduced-motion: reduce) {
  .title-shape,
  .title-drop { animation: none; }
}

@media (max-width: 980px) {
  .topbar { padding: 6px 8px; }
  .topbar h1 { font-size: 15px; }
  #pageTitleText { letter-spacing: 0.5px; gap: 3px; }
  .title-shape { filter: drop-shadow(0 1px 1px rgba(0,0,0,0.5)); }
  .title-drop { text-shadow: 0 1px 4px rgba(91, 140, 255, 0.3); }
  .brand-logo { width: 18px; height: 18px; border-radius: 5px; }
  .topbar .btn { padding: 5px 8px; font-size: 12px; }
  .wrap { grid-template-columns: 1fr; gap: 0; padding: 8px; }
  .hud-row { grid-column: 1 / -1; }
  .left { grid-column: 1 / -1; grid-row: auto; padding: 6px; gap: 6px; }
  .canvas-wrap { max-width: 100%; }
  .side-panel {
    grid-column: 1 / -1;
    grid-row: auto;
    width: auto;
    border-radius: 8px;
    padding: 8px 10px;
  }
  .side-panel .controls { grid-template-columns: 1fr 1fr; gap: 6px; }
  .mode-note { font-size: 11px; }
  .hud { max-width: 100%; gap: 4px; }
  .status { gap: 4px 8px; padding: 4px 8px; border-radius: 7px; }
  .status-main { font-size: 13px; }
  .status-main strong { font-size: 17px; }
  .status-secondary { font-size: 11px; }
  .status-secondary strong { font-size: 12px; }
  .rule-inline { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; }
  .usage-toggle { font-size: 11px; padding: 5px 7px; }
  .usage { margin-top: 2px; font-size: 11px; line-height: 1.35; }
  body.usage-open .usage { max-height: 480px; padding: 8px 10px; }
  .usage strong { font-size: 12px; }
}
