#anaume-app {
    --bg: #0a0e13;
    --panel: #131a22;
    --panel-2: #182230;
    --line: #27313d;
    --text: #e9eef5;
    --muted: #93a3b5;
    --accent: #f0a93b;
    --accent-ink: #22160a;
    --ok: #6ee7a8;
    --ng: #ff7a6b;
    --cell-radius: 4px;
  }

  #anaume-app * { box-sizing: border-box; }



  #anaume-app :focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 8px; }

  /* ---------- ゲーム枠 ---------- */
  #anaume-app {
    box-sizing: border-box;
    position: relative;
    width: min(100%, 430px);
    margin: 0 auto;
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #111925 0%, #0d141b 100%);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 24px 50px -30px #000, inset 0 1px 0 #ffffff0f;
    overflow: hidden;
  }

  #anaume-app .screen { display: flex; flex-direction: column; gap: 0.55rem; padding: 0.7rem; }
  #anaume-app .screen[hidden] { display: none; }

  /* ---------- タイトル / 遊び方 ---------- */
  #anaume-app .hero { padding: 1.6rem 1.1rem 0.4rem; text-align: center; }

  #anaume-app .hero .kicker {
    margin: 0 0 0.5rem;
    font-size: 0.68rem;
    letter-spacing: 0.24em;
    color: var(--accent);
    font-weight: 700;
  }

  #anaume-app .hero h2 {
    margin: 0;
    font-size: 1.72rem;
    line-height: 1.2;
    font-weight: 900;
    letter-spacing: 0.02em;
  }
  #anaume-app .hero h2 span { color: var(--accent); }

  #anaume-app .hero .lead {
    margin: 0.7rem auto 0;
    max-width: 20em;
    font-size: 0.82rem;
    color: var(--muted);
  }

  #anaume-app .hero-art {
    flex: none;
    margin: 1.1rem auto 0.9rem;
    width: 168px;
    height: 96px;
    border-radius: 12px;
    background: #0f1720;
    border: 1px solid var(--line);
    display: grid;
    place-items: center;
    overflow: hidden;
  }
  #anaume-app .hero-art canvas { width: 100%; height: 100%; }

  #anaume-app .menu { flex: none; display: flex; flex-direction: column; gap: 0.5rem; padding: 0 1.1rem 1.2rem; }

  #anaume-app .btn {
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    min-height: 46px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  #anaume-app .btn:hover:not(:disabled) { background: #1e2937; }
  #anaume-app .btn:disabled { opacity: 0.45; cursor: default; }
  #anaume-app .btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
  }
  #anaume-app .btn.primary:hover:not(:disabled) { background: #f6bc5c; }
  #anaume-app .btn.ghost { background: transparent; }

  /* ---------- ゲーム画面 ---------- */
  #anaume-app .topbar {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0 0.15rem;
  }

  #anaume-app .stage-name {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
  }
  #anaume-app .stage-name .no {
    font-size: 0.62rem;
    letter-spacing: 0.16em;
    color: var(--accent);
    font-weight: 700;
  }
  #anaume-app .stage-name .name { font-size: 0.9rem; font-weight: 800; }

  #anaume-app .left-count {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    border-radius: 10px;
    background: var(--panel);
    border: 1px solid var(--line);
  }
  #anaume-app .left-count .label { font-size: 0.6rem; letter-spacing: 0.1em; color: var(--muted); font-weight: 700; }
  #anaume-app .left-count .num { font-size: 1.05rem; font-weight: 800; font-variant-numeric: tabular-nums; }

  #anaume-app .board-wrap {
    flex: none;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #0f1720;
    border: 1px solid var(--line);
  }

  #anaume-app #board {
    display: block;
    width: 100%;
    aspect-ratio: 6 / 8;
    touch-action: none;
  }

  /* NEXT / HOLD */
  #anaume-app .hud { flex: none; display: grid; grid-template-columns: auto auto 1fr; gap: 0.45rem; align-items: stretch; }

  #anaume-app .slot {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.3rem 0.5rem;
    border-radius: 10px;
    background: var(--panel);
    border: 1px solid var(--line);
    min-height: 52px;
  }
  #anaume-app .slot .cap {
    font-size: 0.56rem;
    letter-spacing: 0.13em;
    font-weight: 800;
    color: var(--muted);
    writing-mode: vertical-rl;
    line-height: 1;
  }
  #anaume-app .slot canvas { width: 44px; height: 44px; }
  #anaume-app .next-queue { display: flex; align-items: center; gap: 0.2rem; }
  #anaume-app .next-queue canvas { display: block; width: 39px; height: 39px; }
  #anaume-app .next-queue canvas + canvas { border-left: 1px solid var(--line); }
  #anaume-app .slot.used { opacity: 0.5; }

  #anaume-app .status {
    display: flex;
    align-items: center;
    padding: 0.3rem 0.55rem;
    border-radius: 10px;
    background: var(--panel);
    border: 1px solid var(--line);
    font-size: 0.72rem;
    color: var(--muted);
    line-height: 1.35;
    min-height: 52px;
  }
  #anaume-app .status.warn { color: #ffd08a; border-color: #6b4a12; background: #21180a; }

  /* 操作 */
  #anaume-app .controls, #anaume-app .pad { display: grid; align-items: stretch; gap: 0.35rem; min-width: 0; }
  #anaume-app .controls { grid-template-columns: minmax(0, 2fr) minmax(0, 3.35fr); gap: 0.6rem; }
  #anaume-app .pad-move { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #anaume-app .pad-actions { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.35fr); }

  #anaume-app .key {
    font: inherit;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-bottom-width: 3px;
    border-radius: 12px;
    min-width: 0;
    min-height: 52px;
    padding: 0.25rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }
  #anaume-app .key .glyph { font-size: 1.25rem; line-height: 1; }
  #anaume-app .key .cap2 { font-size: 0.56rem; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
  #anaume-app .key:active { transform: translateY(1px); border-bottom-width: 2px; }
  #anaume-app .key:hover:not(:disabled) { background: #1e2937; }
  #anaume-app .key:disabled { opacity: 0.4; }
  #anaume-app .key.primary {
    background: var(--accent);
    border-color: #c8892b;
    color: var(--accent-ink);
  }
  #anaume-app .key.primary .cap2 { color: #5c4212; }
  #anaume-app .key.primary:hover:not(:disabled) { background: #f6bc5c; }

  #anaume-app .hidden-input {
    position: absolute;
    width: 1px; height: 1px;
    opacity: 0;
    pointer-events: none;
    left: -9999px;
  }

  #anaume-app .foot { margin: 0; text-align: center; font-size: 0.66rem; color: var(--muted); }

  /* ---------- オーバーレイ ---------- */
  #anaume-app .overlay {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    text-align: center;
    background: #0b1119d6;
    backdrop-filter: blur(2px);
    z-index: 5;
  }
  #anaume-app .overlay.show { display: flex; animation: anaume-fade 200ms ease-out; }
  @keyframes anaume-fade { from { opacity: 0; } to { opacity: 1; } }

  #anaume-app .overlay h2 { margin: 0; font-size: 1.35rem; font-weight: 900; letter-spacing: 0.02em; }
  #anaume-app .overlay.win h2 { color: var(--accent); }
  #anaume-app .overlay p { margin: 0; font-size: 0.8rem; color: var(--muted); }
  #anaume-app .overlay .sub { font-size: 0.95rem; color: var(--text); font-weight: 700; }
  #anaume-app .overlay .acts { display: flex; flex-direction: column; gap: 0.4rem; width: min(240px, 100%); margin-top: 0.4rem; }

  /* やり直すチップ */
  #anaume-app .retry-row { display: flex; justify-content: center; gap: 0.45rem; }
  #anaume-app .chip {
    font: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 999px;
    min-height: 44px;
    padding: 0.28rem 0.85rem;
    cursor: pointer;
    touch-action: manipulation;
  }
  #anaume-app .chip:disabled { opacity: 0.45; cursor: default; }
  #anaume-app .chip:hover:not(:disabled) { color: var(--text); border-color: #3a4757; }

  /* ---------- 遊び方 ---------- */
  #anaume-app .help { padding: 0.4rem 0.2rem 0.2rem; }
  #anaume-app .help h2 { margin: 0 0 0.6rem; font-size: 1.1rem; font-weight: 900; }
  #anaume-app .help ol, #anaume-app .help ul { margin: 0 0 0.8rem; padding-left: 1.15rem; font-size: 0.8rem; color: #c8d4e2; }
  #anaume-app .help li { margin-bottom: 0.35rem; }
  #anaume-app .help b { color: var(--accent); }
  #anaume-app .help .keys { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 0.6rem; font-size: 0.76rem; color: var(--muted); margin: 0 0 0.9rem; }
  #anaume-app kbd {
    font: inherit;
    font-size: 0.72rem;
    padding: 0.05rem 0.35rem;
    background: #1a2431;
    border: 1px solid #2f3d4d;
    border-bottom-width: 2px;
    border-radius: 5px;
    color: #d6e1ee;
    white-space: nowrap;
  }

  #anaume-app .sr-only {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }

  @media (max-width: 380px) {
    #anaume-app { border-radius: 14px; }
    #anaume-app .hero h2 { font-size: 1.5rem; }
    #anaume-app .controls { gap: 0.45rem; }
    #anaume-app .slot { padding-inline: 0.3rem; gap: 0.3rem; }
    #anaume-app .slot canvas { width: 35px; height: 35px; }
    #anaume-app .next-queue canvas { width: 32px; height: 32px; }
  }

  @media (max-height: 830px) {
    #anaume-app .board-wrap { width: min(100%, max(138px, calc(75dvh - 231px))); align-self: center; }
  }

  @media (min-width: 600px) and (max-height: 520px) and (orientation: landscape) {
    #anaume-app { width: min(100%, 630px); }
    #anaume-app #screenGame:not([hidden]) {
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(250px, 1.25fr);
      grid-template-rows: repeat(4, auto) 1fr;
      align-items: start;
    }
    #anaume-app .board-wrap {
      grid-column: 1;
      grid-row: 1 / span 5;
      width: min(100%, calc(75dvh - 36px));
      justify-self: center;
    }
    #anaume-app .topbar, #anaume-app .hud, #anaume-app .controls, #anaume-app .retry-row, #anaume-app .foot { grid-column: 2; }
  }

  @media (min-width: 700px) and (min-height: 700px) {
    #anaume-app { width: 430px; }
  }

  @media (prefers-reduced-motion: reduce) {
    #anaume-app .overlay.show { animation-duration: 1ms; }
  }

  #anaume-app #screenHelp {
    max-height: 100dvh;
    overflow-y: auto;
  }

  #anaume-app { scroll-margin-block: var(--anaume-safe-top, 0px) var(--anaume-safe-bottom, 0px); }
  #anaume-app .sound-options { display: grid; gap: .35rem; margin: .75rem 0 1rem; }
  #anaume-app .sound-options label { display: flex; align-items: center; gap: .5rem; min-height: 44px; }
  #anaume-app .sound-options input { accent-color: var(--accent); }
  #anaume-app #soundVolume { width: 100%; min-height: 44px; }
  #anaume-app button:disabled { opacity: .45; cursor: default; }

  #anaume-app.ad-compact .screen { gap: .25rem; padding-block: .35rem; }
  #anaume-app.ad-compact .hero { padding-block: .45rem 0; }
  #anaume-app.ad-compact .hero-art, #anaume-app.ad-compact .foot { display: none; }
  #anaume-app.ad-compact .menu { padding-bottom: .35rem; }
  #anaume-app.ad-compact .hud .slot, #anaume-app.ad-compact .hud .status { min-height: 44px; }
  #anaume-app.ad-compact .key { min-height: 44px; }
  #anaume-app.ad-compact .board-wrap {
    width: min(100%, max(114px, calc((var(--anaume-safe-height) - 218px) * .75)));
    align-self: center;
  }
  #anaume-app.ad-compact #screenHelp, #anaume-app.ad-compact #screenSettings {
    max-height: var(--anaume-safe-height);
    overflow-y: auto;
  }
  #anaume-app.ad-compact .overlay { padding: .3rem; gap: .2rem; overflow-y: auto; }
  #anaume-app.ad-compact .overlay h2 { font-size: 1rem; }
  #anaume-app.ad-compact .overlay .acts { gap: .1rem; margin-top: 0; }

  @media (min-width: 600px) and (max-height: 520px) and (orientation: landscape) {
    #anaume-app.ad-compact .board-wrap {
      width: min(100%, max(114px, calc((var(--anaume-safe-height) - 12px) * .75)));
    }
  }
