/* Massimu 6: app styles on top of /shared/css/aps.css */

.m6-h1 { margin-top: var(--space-4); }
.m6-back { margin-left: -14px; }

/* ---------- Start ---------- */
.m6-start { padding: clamp(24px, 5vw, 64px) 0 var(--space-6);
  background: radial-gradient(60% 70% at 90% 10%, rgba(243, 232, 210, .9), transparent 70%), radial-gradient(50% 60% at 0% 100%, rgba(237, 241, 235, .8), transparent 70%); }
.m6-start__grid { display: grid; gap: var(--space-6); align-items: center; }
.m6-start__text h1 { font-size: clamp(2.6rem, 1.6rem + 5vw, 4.4rem); margin-bottom: 0; }
.m6-start__actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin-top: var(--space-5); max-width: 460px; }
.m6-start__actions .btn--large { grid-column: 1 / -1; }
.m6-start__actions .btn--secondary { padding-left: 12px; padding-right: 12px; }
.m6-start__actions .btn--secondary:last-child { grid-column: 1 / -1; }
.m6-start__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-top: var(--space-4); }
.m6-start__art { margin: 0; justify-self: center; width: min(72vw, 340px); }
.m6-start__art img { display: block; width: 100%; height: auto; border-radius: var(--radius); box-shadow: var(--shadow-l); background: #f4ead7; }
@media (min-width: 860px) {
  .m6-start__grid { grid-template-columns: 1.1fr 0.9fr; }
  .m6-start__art { width: min(100%, 360px); }
}
.m6-sound { gap: 8px; }
.m6-sound svg { width: 22px; height: 22px; }

.m6-how { margin-top: var(--space-7); }
.m6-how h2 { font-size: 1.5rem; }
.m6-how__list { list-style: none; margin: var(--space-4) 0 0; padding: 0; display: grid; gap: var(--space-3); grid-template-columns: 1fr; counter-reset: how; }
.m6-how__list li { display: flex; gap: var(--space-3); align-items: flex-start; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-s); }
.m6-how__list svg { width: 40px; height: 40px; flex: none; color: var(--aps-green); }
.m6-how__list p { margin: 0; color: var(--ink-2); font-size: 0.97rem; }
@media (min-width: 720px) { .m6-how__list { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1040px) { .m6-how__list { grid-template-columns: repeat(4, 1fr); } .m6-how__list li { flex-direction: column; } }

/* ---------- Levels ---------- */
.m6-levels { list-style: none; margin: var(--space-5) 0 0; padding: 0; display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(min(46%, 180px), 1fr)); }
.m6-level { position: relative; display: flex; flex-direction: column; gap: 2px; height: 100%; min-height: 128px; padding: 14px 14px 12px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-s); color: var(--ink); text-decoration: none; transition: transform .18s var(--ease), box-shadow .18s, border-color .18s; }
a.m6-level:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-strong); color: var(--ink); }
.m6-level__n { font-size: 1.6rem; font-weight: 700; color: var(--gold-text); line-height: 1.1; }
.m6-level__name { font-weight: 700; color: var(--aps-green-dark); line-height: 1.25; }
.m6-level__meta { font-size: 0.8rem; color: var(--ink-3); }
.m6-level__stars { margin-top: auto; padding-top: 6px; }
.m6-level__best { font-size: 0.78rem; color: var(--ink-3); }
.m6-level.is-locked { background: var(--paper-2); color: var(--ink-3); box-shadow: none; }
.m6-level.is-locked .m6-level__n, .m6-level.is-locked .m6-level__name { color: var(--ink-3); }
.m6-level__lock { position: absolute; top: 14px; right: 14px; color: var(--ink-3); }
.m6-stars { display: inline-flex; gap: 2px; vertical-align: middle; }

/* ---------- Daily ---------- */
.m6-daily-card { margin-top: var(--space-5); }
.m6-daily-card h2 { font-size: 1.4rem; }
.m6-daily-cal { margin-bottom: var(--space-3); }
.m6-daily-best { font-weight: 700; color: var(--gold-text); }
.m6-daily-card .notice { margin-bottom: var(--space-4); }

/* ---------- Leaderboard ---------- */
.m6-board { margin-top: var(--space-5); min-height: 120px; }
.m6-board__loading { display: grid; place-items: center; padding: var(--space-6); }
.m6-board__empty { padding: var(--space-5) 0; }
.m6-prize { margin-bottom: var(--space-4); }
.m6-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); font-size: 0.97rem; }
.m6-table th:first-child { border-top-left-radius: var(--radius); }
.m6-table th:last-child { border-top-right-radius: var(--radius); }
.m6-table caption { text-align: left; font-weight: 700; color: var(--ink-2); padding: 0 0 var(--space-2); font-size: 0.9rem; }
.m6-table th { text-align: left; font-size: 0.78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); background: var(--paper); padding: 10px 12px; border-bottom: 1px solid var(--line); }
.m6-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.m6-table tr:last-child td { border-bottom: 0; }
.m6-table td:nth-child(2) { max-width: 40vw; overflow-wrap: anywhere; font-weight: 600; }
.m6-board__rank { color: var(--gold-text); font-weight: 700; width: 3.5em; }
.m6-board__score { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.m6-table th:last-child { text-align: right; }

/* ---------- Game ---------- */
.m6-game { --bar-h: 52px; --say-h: 76px; --ctl-h: 64px; width: 100%; max-width: 1080px; margin: 0 auto; padding: 8px clamp(12px, 3vw, 24px) 0; }
.m6-game__bar { display: flex; align-items: center; gap: 6px; min-height: var(--bar-h); }
.m6-game__title { flex: 1; min-width: 0; margin: 0; display: flex; flex-direction: column; line-height: 1.15; letter-spacing: 0; }
.m6-game__kicker { font-size: 0.72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--gold-text); }
.m6-game__name { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m6-iconbtn { width: 44px; min-width: 44px; min-height: 44px; }
.m6-iconbtn svg { width: 22px; height: 22px; }
.m6-chip { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; min-height: 34px; border-radius: 999px; background: var(--white); border: 1px solid var(--line); font-weight: 700; font-size: 0.92rem; color: var(--aps-green-dark); font-variant-numeric: tabular-nums; }
.m6-chip svg { width: 16px; height: 16px; color: var(--aps-green-light); }
.m6-chip__max { color: var(--ink-3); font-weight: 600; }
.m6-chip.is-over { background: var(--gold-soft); border-color: var(--gold); color: var(--gold-text); }
.m6-chip.is-over .m6-chip__max { color: var(--gold-text); text-decoration: line-through; }

.m6-game__main { display: flex; flex-direction: column; gap: 8px; }
.m6-game__playfield { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.m6-saliba { display: flex; align-items: center; gap: 10px; height: var(--say-h); }
.m6-saliba__face { flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--gold-soft); border: 1.5px solid var(--gold); }
.m6-saliba__bubble { position: relative; flex: 1; min-width: 0; background: var(--white); border: 1.5px solid var(--line-strong); border-radius: 16px; padding: 5px 12px; height: calc(var(--say-h) - 4px); overflow: hidden; display: flex; flex-direction: column; justify-content: center; }
.m6-saliba__bubble::before { content: ""; position: absolute; left: -8px; top: 50%; width: 12px; height: 12px; background: var(--white); border-left: 1.5px solid var(--line-strong); border-bottom: 1.5px solid var(--line-strong); transform: translateY(-50%) rotate(45deg); }
.m6-saliba__mt { margin: 0; font-weight: 700; color: var(--aps-green-dark); line-height: 1.18; font-size: 0.9rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.m6-saliba__en { margin: 0; color: var(--ink-2); font-size: 0.78rem; line-height: 1.18; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.m6-saliba.is-hint .m6-saliba__mt { display: none; }
.m6-saliba.is-hint .m6-saliba__en { color: var(--ink-2); font-weight: 600; font-size: 0.9rem; white-space: normal; }
.m6-saliba.is-pop .m6-saliba__bubble { animation: m6-pop .28s var(--ease); }
.m6-next { flex: none; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.m6-next__label { font-size: 0.66rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.m6-next canvas { width: 46px; height: 46px; background: var(--white); border-radius: var(--radius-s); border: 1px solid var(--line); }
.m6-next.is-empty canvas { opacity: .35; }
@media (min-width: 900px) { .m6-next canvas { width: 54px; height: 54px; } }
@keyframes m6-pop { from { transform: scale(.94); opacity: .4; } }

.m6-stage-wrap { display: flex; justify-content: center; }
.m6-game { --stage-w: min(100%, calc((100vh - 64px - var(--bar-h) - var(--say-h) - var(--ctl-h) - 44px) * 0.6111)); }
@supports (height: 100dvh) { .m6-game { --stage-w: min(100%, calc((100dvh - 64px - var(--bar-h) - var(--say-h) - var(--ctl-h) - 44px) * 0.6111)); } }
.m6-stage { position: relative; width: var(--stage-w); border-radius: var(--radius); background: #f4ead7; box-shadow: var(--shadow); outline: none; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.m6-stage { min-width: 260px; }
.m6-stage:focus-visible { box-shadow: var(--shadow), 0 0 0 3px var(--paper), 0 0 0 5px var(--aps-green); }
.m6-stage canvas { display: block; width: 100%; aspect-ratio: 330 / 540; border-radius: var(--radius); touch-action: none; cursor: grab; }
.m6-stage canvas:active { cursor: grabbing; }
.m6-stage.is-closing { box-shadow: var(--shadow), 0 0 0 3px var(--aps-green-tint), 0 0 0 5px var(--aps-green-light); }
.m6-stage__loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: rgba(251, 248, 243, .92); border-radius: var(--radius); color: var(--ink-2); font-weight: 600; padding: 16px; text-align: center; }
.m6-hintcard { position: absolute; left: 50%; top: 40%; transform: translateX(-50%); width: min(92%, 340px); z-index: 2; }
.m6-hint { padding: 16px 18px; }
.m6-hint h2 { font-size: 1.1rem; margin-bottom: 4px; }
.m6-hint p { font-size: 0.92rem; margin-bottom: 12px; }

.m6-side { display: flex; flex-direction: column; gap: 8px; }
.m6-queue { display: none; }
.m6-queue__label { font-size: 0.78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.m6-controls { display: flex; gap: 6px; min-height: var(--ctl-h); }
.m6-ctl { flex: 1 1 0; min-width: 44px; min-height: 56px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px 4px; border-radius: var(--radius); border: 1.5px solid var(--line-strong); background: var(--white); color: var(--aps-green-dark); font: inherit; font-weight: 700; font-size: 0.78rem; line-height: 1.1; cursor: pointer; transition: background .15s, border-color .15s, transform .1s; -webkit-tap-highlight-color: transparent; }
.m6-ctl svg { width: 24px; height: 24px; flex: none; }
.m6-ctl:hover { border-color: var(--aps-green-light); background: var(--aps-green-mist); }
.m6-ctl:active { transform: translateY(1px); }
.m6-ctl--main { flex-grow: 1.5; background: var(--aps-green); border-color: var(--aps-green); color: var(--white); font-size: 0.86rem; }
.m6-ctl--main:hover { background: var(--aps-green-dark); border-color: var(--aps-green-dark); }
.m6-ctl--step { font-size: 1rem; }
.m6-ctl__cap { font-size: 0.7rem; font-weight: 600; color: var(--ink-2); }
.m6-ctl:disabled { opacity: .42; cursor: not-allowed; transform: none; }
.m6-ctl--main:disabled { background: var(--aps-green-light); }
.m6-after { min-height: var(--ctl-h); display: flex; align-items: center; }
.m6-after .btn-row { width: 100%; justify-content: center; }
.m6-kbd { display: none; margin: 0; }

@media (max-width: 380px) {
  .m6-ctl__cap { display: none; }
  .m6-chip--time { display: none; }
}

@media (min-width: 900px) {
  .m6-game { --say-h: 76px; }
  .m6-saliba__mt { font-size: 1rem; }
  .m6-saliba__en { font-size: 0.86rem; }
  .m6-game { --stage-w: min(560px, calc((100vh - 76px - var(--bar-h) - var(--say-h) - 48px) * 0.6111)); }
  @supports (height: 100dvh) { .m6-game { --stage-w: min(560px, calc((100dvh - 76px - var(--bar-h) - var(--say-h) - 48px) * 0.6111)); } }
  .m6-game__bar, .m6-game__main { max-width: calc(var(--stage-w) + 70px + 300px + var(--space-6)); margin-left: auto; margin-right: auto; }
  .m6-game__main { display: grid; grid-template-columns: calc(var(--stage-w) + 70px) 300px; gap: var(--space-6); align-items: start; justify-content: center; }
  .m6-stage-wrap { justify-content: center; }
  .m6-side { padding-top: calc(var(--say-h) + 8px); gap: var(--space-4); position: sticky; top: 90px; }
  .m6-queue { display: block; gap: var(--space-3); align-items: center; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-s); }
  .m6-queue__now { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
  .m6-queue__now .m6-queue__label { text-transform: none; letter-spacing: 0; font-size: 1.02rem; color: var(--aps-green-dark); }
  .m6-queue__now .badge { align-self: flex-start; }
  .m6-controls { display: grid; grid-template-columns: 1fr 1fr 1fr; }
  #m6-rot-left { grid-column: 1; grid-row: 1; }
  #m6-rot-right { grid-column: 2 / 4; grid-row: 1; }
  #m6-step { grid-column: 1; grid-row: 2; }
  #m6-drop { grid-column: 2 / 4; grid-row: 2; }
  #m6-leave { grid-column: 1 / 4; grid-row: 3; flex-direction: row; min-height: 52px; }
  #m6-leave .m6-ctl__cap { font-size: 0.86rem; color: inherit; }
  .m6-ctl { min-height: 64px; flex-direction: row; gap: 8px; font-size: 0.92rem; }
  .m6-ctl--step { flex-direction: column; gap: 2px; }
  .m6-kbd { display: block; }
}

/* ---------- Score dialog ---------- */
.m6-dialog .dialog__body h2 { text-align: center; padding-right: 0; margin-top: 4px; }
.m6-score__stars { display: flex; justify-content: center; margin-bottom: 4px; }
.m6-score__stars .m6-stars { gap: 6px; }
.m6-score__stars svg:nth-child(2) { transform: translateY(-6px); }
.m6-score__level { text-align: center; margin: 0 0 var(--space-2); font-size: 0.95rem; }
.m6-score__total { display: flex; flex-direction: column; align-items: center; margin: 0 0 var(--space-3); }
.m6-score__num { font-size: 2.6rem; font-weight: 700; color: var(--aps-green-dark); line-height: 1; font-variant-numeric: tabular-nums; }
.m6-score__label { font-size: 0.78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--gold-text); font-weight: 700; margin-top: 4px; }
.m6-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 0 0 var(--space-4); }
.m6-stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 8px 12px; }
.m6-stat dt { font-size: 0.75rem; color: var(--ink-3); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.m6-stat dd { margin: 0; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.m6-score__actions { margin-bottom: var(--space-4); }
.m6-submit { border-top: 1px solid var(--line); padding-top: var(--space-4); }
.m6-submit h3 { font-size: 1.05rem; }
.m6-submit__row { display: flex; gap: 8px; }
.m6-submit__row .input { flex: 1; min-width: 0; }
.m6-submit .field { margin-bottom: 0; }
.m6-submit .btn--small { margin-top: var(--space-3); }

@media (prefers-reduced-motion: reduce) {
  .m6-saliba.is-pop .m6-saliba__bubble { animation: none; }
}
