:root {
    --bg: #faf9f6;
    --bg-sub: #f3f1eb;
    --fg: #111111;
    --fg-sub: #555555;
    --border: #e2dfd5;
    --muted: #888888;

    /* リズム＝オレンジ（サイト掲載カリキュラム化の原則 §2 の配色ルール） */
    --r-main:   #ea580c;
    --r-mid:    #f97316;
    --r-light:  #fb923c;
    --r-pale:   #fdba74;
    --r-faint:  #fed7aa;
    --r-bg:     #fff7ed;
    --r-border: #ffedd5;

    --g-teal:   #0891b2;

    --font-sans: 'Space Grotesk', system-ui, sans-serif;
    --font-jp:   'Noto Sans JP', sans-serif;
    --radius:    8px;
    --radius-lg: 16px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-jp);
    background: transparent;
    color: var(--fg);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 16px;
}

.rl-widget {
    background: #ffffff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 760px;
    width: 100%;
}

/* ---------- ヘッダー ---------- */
.rl-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    text-align: center;
}

.rl-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--r-main);
    letter-spacing: 0.04em;
}

.rl-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

/* ---------- ボタン ---------- */
.rl-btn {
    background: var(--bg-sub);
    color: var(--fg);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.86rem;
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 38px;
}

.rl-btn:hover { background: #e5e3db; }
.rl-btn:focus-visible { outline: 2px solid var(--g-teal); outline-offset: 2px; }

.rl-btn-primary {
    background: var(--r-main);
    color: #fff;
    border-color: var(--r-main);
    min-width: 104px;
}
.rl-btn-primary:hover { background: #c2410c; }

.rl-btn-active {
    background: var(--r-main) !important;
    color: #fff !important;
    border-color: var(--r-main) !important;
}

.rl-btn-sm {
    padding: 6px 10px;
    font-size: 0.78rem;
    min-height: 32px;
}

/* ---------- BPM スライダー ---------- */
.rl-bpm {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.rl-bpm-label {
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--fg);
    min-width: 92px;
    text-align: right;
}

.rl-bpm input[type="range"] {
    flex: 1 1 200px;
    min-width: 160px;
    max-width: 340px;
    accent-color: var(--r-main);
    height: 28px;
    cursor: pointer;
}

/* ---------- 音価モード ---------- */
.rl-values {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.rl-value-row {
    display: grid;
    grid-template-columns: 76px 1fr;
    align-items: center;
    gap: 10px;
    background: none;
    border: 0;
    padding: 0;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
}

.rl-value-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--fg-sub);
}

.rl-value-bar {
    position: relative;
    display: flex;
    gap: 3px;
    height: 30px;
    border-radius: 6px;
    overflow: hidden;
}

.rl-cellbox {
    flex: 1;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    font-weight: 700;
    color: #fff;
    transition: transform 0.08s ease, filter 0.08s ease;
}

.rl-value-row:hover .rl-cellbox { filter: brightness(1.06); }

.rl-cellbox.is-hit {
    transform: scaleY(1.14);
    filter: brightness(1.18);
    box-shadow: 0 0 0 2px rgba(234,88,12,0.35);
}

.rl-value-hint {
    font-size: 0.74rem;
    color: var(--muted);
    text-align: center;
    margin-top: 2px;
}

/* ---------- ビートグリッドモード ---------- */
.rl-grid-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.rl-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 340px;
}

.rl-grid-row {
    display: grid;
    grid-template-columns: 58px 1fr;
    align-items: center;
    gap: 8px;
}

.rl-grid-label {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--fg-sub);
}

.rl-grid-cells {
    display: grid;
    gap: 3px;
}

.rl-cell {
    aspect-ratio: 1 / 1;
    min-height: 26px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: #fbfaf7;
    cursor: pointer;
    padding: 0;
    transition: background 0.1s ease, transform 0.08s ease;
}

.rl-cell.is-beat-head { border-color: #94a3b8; background: #f1f5f9; }
.rl-cell.is-bar-head  { border-color: #475569; border-width: 2px; }
.rl-cell:hover { background: var(--r-faint); }

.rl-cell.is-on { background: var(--r-main); border-color: var(--r-main); }
.rl-cell.is-on.rl-snare { background: #d97706; border-color: #d97706; }
.rl-cell.is-on.rl-hihat { background: #eab308; border-color: #eab308; }

.rl-cell.is-playing { transform: scale(1.12); box-shadow: 0 0 0 2px rgba(234,88,12,0.4); }

.rl-beatnum {
    display: grid;
    gap: 3px;
    font-family: var(--font-sans);
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--muted);
    text-align: center;
}

/* ---------- テンポモード ---------- */
.rl-tempo {
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: center;
    width: 100%;
}

.rl-bpm-display {
    font-family: var(--font-sans);
    font-size: 2.6rem;
    font-weight: 700;
    color: var(--r-main);
    line-height: 1;
}

.rl-bpm-unit {
    font-size: 0.9rem;
    color: var(--muted);
    margin-left: 6px;
}

.rl-pulse-row {
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: center;
    min-height: 40px;
}

.rl-pulse {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--r-faint);
    transition: transform 0.06s ease, background 0.06s ease;
}

.rl-pulse.is-accent { background: var(--r-pale); }
.rl-pulse.is-hit { background: var(--r-main); transform: scale(1.35); }

.rl-math {
    background: var(--r-bg);
    border: 1.5px solid var(--r-border);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 0.78rem;
    color: #9a3412;
    text-align: center;
    line-height: 1.7;
}

/* ---------- フッター ---------- */
.rl-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.72rem;
    color: var(--muted);
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

/* ---------- レスポンシブ ---------- */
@media (max-width: 600px) {
    body { padding: 10px; }
    .rl-widget { padding: 14px; gap: 12px; }
    .rl-value-row { grid-template-columns: 62px 1fr; gap: 8px; }
    .rl-value-name { font-size: 0.72rem; }
    .rl-grid-row { grid-template-columns: 46px 1fr; gap: 6px; }
    .rl-grid-label { font-size: 0.68rem; }
    .rl-cell { min-height: 20px; }
    .rl-bpm-label { min-width: 100%; text-align: center; }
    .rl-bpm-display { font-size: 2.1rem; }
    .rl-btn { padding: 7px 11px; font-size: 0.8rem; }
}
