/* =============================================
   ヨット道場 — 夜の道場 × ダイスバー
   Warm walnut & brass, green felt dice tray
   ============================================= */

/* --- Reset --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'YuGothic', 'Yu Gothic Medium', 'Hiragino Kaku Gothic Pro', 'Meiryo', sans-serif;
    background-color: #0f0d0a;
    background-image:
        /* faint wood-grain texture */
        repeating-linear-gradient(
            88deg,
            transparent 0, transparent 2px,
            rgba(60, 40, 20, 0.025) 2px, rgba(60, 40, 20, 0.025) 3px
        ),
        /* warm overhead lamp glow */
        radial-gradient(ellipse 700px 480px at 50% 10%, rgba(110, 72, 28, 0.11) 0%, transparent 100%);
    color: #c8bca4;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Container --- */
.game-container {
    width: 100%;
    max-width: 560px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
}

.hidden { display: none !important; }

/* =============================================
   Start Screen
   ============================================= */
.start-screen {
    text-align: center;
    gap: 24px;
}

.game-title {
    font-family: 'Shippori Mincho B1', 'Yu Mincho', 'Hiragino Mincho Pro', serif;
    font-size: 3rem;
    font-weight: 800;
    color: #c49a3c;
    letter-spacing: 0.3em;
    text-indent: 0.3em;
    position: relative;
    line-height: 1.3;
    text-shadow:
        0 0 40px rgba(196, 154, 60, 0.12),
        0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Five pips — the five dice */
.game-title::after {
    content: '●   ●   ●   ●   ●';
    display: block;
    font-family: sans-serif;
    font-size: 0.3rem;
    letter-spacing: 0.2em;
    color: #3a2e20;
    margin-top: 18px;
    text-indent: 0;
    font-weight: 400;
}

.game-subtitle {
    font-size: 0.88rem;
    color: #6a5e4a;
    letter-spacing: 0.06em;
    margin-top: -10px;
}

/* --- Settings --- */
.settings {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    max-width: 340px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.setting-group label {
    font-size: 0.78rem;
    color: #6a5e4a;
    text-align: left;
    letter-spacing: 0.05em;
}

.btn-group {
    display: flex;
    background: #16120e;
    border-radius: 8px;
    padding: 3px;
    border: 1px solid #2a2218;
}

.btn-group .btn {
    flex: 1;
    padding: 10px 8px;
    border: none;
    background: transparent;
    color: #6a5e4a;
    font-size: 0.92rem;
    border-radius: 6px;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
    letter-spacing: 0.03em;
}

.btn-group .btn:hover {
    color: #9a8e7a;
}

.btn-group .btn.active {
    background: #221e18;
    color: #c49a3c;
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* --- Audio --- */
.audio-toggles {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.audio-toggle-btn {
    padding: 5px 14px;
    background: transparent;
    border: 1px solid #2a2218;
    color: #7a6e58;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 500;
    transition: all 0.2s;
    min-width: 78px;
}

.audio-toggle-btn:hover {
    border-color: #3a3028;
    color: #a09080;
}

.audio-toggle-btn.audio-off {
    color: #3a3428;
    border-color: #201c16;
}

/* --- Start Button --- */
.start-btn {
    background: linear-gradient(180deg, #4a3820 0%, #3a2c18 100%);
    color: #e8dcc4;
    border: 1px solid #5a4830;
    padding: 14px 52px;
    font-size: 1.05rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease-out;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    letter-spacing: 0.15em;
}

.start-btn:hover {
    background: linear-gradient(180deg, #5a4828 0%, #4a3820 100%);
    border-color: #6a5838;
    transform: translateY(-1px);
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(196, 154, 60, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.start-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* --- Help --- */
.help-toggle {
    background: none;
    border: 1px solid #2a2218;
    color: #6a5e4a;
    padding: 8px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.82rem;
    transition: border-color 0.2s, color 0.2s;
    letter-spacing: 0.03em;
}

.help-toggle:hover {
    border-color: #3a3028;
    color: #a09080;
}

.help-section {
    text-align: left;
    background: #16120e;
    border: 1px solid #2a2218;
    border-radius: 8px;
    padding: 20px 22px;
    width: 100%;
    max-width: 400px;
}

.help-section h3 {
    font-family: 'Shippori Mincho B1', 'Yu Mincho', serif;
    font-size: 1rem;
    color: #c49a3c;
    margin-bottom: 14px;
    letter-spacing: 0.1em;
}

.help-content p,
.help-content li {
    font-size: 0.83rem;
    line-height: 1.75;
    margin-bottom: 8px;
    color: #8a7e6a;
}

.help-content ul {
    padding-left: 1.5em;
    margin-bottom: 8px;
}

/* --- Footer --- */
.game-footer {
    margin-top: 24px;
    font-size: 0.72rem;
    color: #3a3428;
    line-height: 1.8;
}

.game-footer a {
    color: #5a4e3a;
    text-decoration: none;
    transition: color 0.2s;
}

.game-footer a:hover {
    color: #c49a3c;
}

/* =============================================
   Game Screen
   ============================================= */
.game-screen {
    justify-content: flex-start;
    padding: 10px 12px 20px;
    gap: 10px;
}

/* --- Header Bar --- */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 14px;
    background: #16120e;
    border: 1px solid #262018;
    border-radius: 8px;
}

.round-info {
    font-size: 0.78rem;
    color: #6a5e4a;
}

.turn-indicator {
    font-size: 0.88rem;
    font-weight: 600;
    color: #8aaa70;
    padding: 4px 16px;
    background: rgba(100, 140, 70, 0.08);
    border: 1px solid rgba(100, 140, 70, 0.12);
    border-radius: 6px;
    transition: all 0.3s;
}

.turn-indicator.ai-turn {
    color: #c07848;
    background: rgba(192, 120, 72, 0.08);
    border-color: rgba(192, 120, 72, 0.12);
}

.roll-info {
    font-size: 0.78rem;
    color: #6a5e4a;
}

/* =============================================
   Dice Area — the green-felt focal point
   ============================================= */
.dice-area {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.dice-tray {
    display: flex;
    gap: 10px;
    justify-content: center;
    padding: 22px 16px;
    /* baize green with felt grain */
    background-color: #1a2e1c;
    background-image:
        radial-gradient(circle, rgba(255, 255, 255, 0.014) 1px, transparent 1px);
    background-size: 4px 4px;
    border-radius: 14px;
    /* wooden frame */
    border: 3px solid #2c2015;
    box-shadow:
        0 6px 24px rgba(0, 0, 0, 0.5),
        inset 0 2px 8px rgba(0, 0, 0, 0.4),
        inset 0 -1px 3px rgba(255, 255, 255, 0.02),
        0 0 0 1px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 400px;
    position: relative;
}

/* stitched rim inside felt */
.dice-tray::before {
    content: '';
    position: absolute;
    inset: 7px;
    border: 1px dashed rgba(100, 160, 80, 0.07);
    border-radius: 9px;
    pointer-events: none;
}

/* --- Die --- */
.die {
    width: 58px;
    height: 58px;
    position: relative;
    cursor: pointer;
    transition: transform 0.15s ease-out;
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.die:hover {
    transform: translateY(-3px);
}

.die:active {
    transform: scale(0.93);
}

.die-face {
    width: 100%;
    height: 100%;
    background: linear-gradient(145deg, #f2e8d0, #e0d4b8, #d8ccb0);
    border-radius: 12px;
    position: relative;
    box-shadow:
        0 4px 10px rgba(0, 0, 0, 0.55),
        0 1px 2px rgba(0, 0, 0, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.4),
        inset 0 -2px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #b8a888;
}

/* --- Pips (carved indentation) --- */
.pip {
    position: absolute;
    width: 17%;
    height: 17%;
    background: radial-gradient(circle at 40% 35%, #3a3530, #1e1c18);
    border-radius: 50%;
    box-shadow:
        inset 0 1px 2px rgba(0, 0, 0, 0.5),
        0 1px 0 rgba(255, 255, 255, 0.12);
}

.pip-tl { top: 16%; left: 16%; }
.pip-tr { top: 16%; right: 16%; }
.pip-ml { top: 41%; left: 16%; }
.pip-c  { top: 41%; left: 41%; }
.pip-mr { top: 41%; right: 16%; }
.pip-bl { bottom: 16%; left: 16%; }
.pip-br { bottom: 16%; right: 16%; }

/* --- Hold --- */
.die.held {
    transform: translateY(2px);
}

.die.held .die-face {
    border-color: #c49a3c;
    box-shadow:
        0 0 18px rgba(196, 154, 60, 0.35),
        0 2px 4px rgba(0, 0, 0, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

.held-label {
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.58rem;
    font-weight: 700;
    color: #c49a3c;
    letter-spacing: 0.15em;
    white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* --- Edit mode --- */
.die.editable .die-face {
    border-color: #5a8a50;
    cursor: pointer;
}

.die.editable:hover .die-face {
    box-shadow:
        0 0 14px rgba(90, 138, 80, 0.25),
        0 4px 10px rgba(0, 0, 0, 0.45),
        inset 0 2px 0 rgba(255, 255, 255, 0.4);
}

.edit-label {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    color: #5a8a50;
}

.die.ai-die {
    opacity: 0.6;
    cursor: default;
}

/* --- Rolling animation --- */
.die.rolling {
    opacity: 0.85;
}
.die.rolling .die-face {
    animation: dicePulse 0.14s ease-in-out infinite alternate;
}
.die.settle-bump .die-face {
    animation: settleBump 0.16s ease-out;
}

@keyframes dicePulse {
    from { filter: brightness(0.9); }
    to   { filter: brightness(1.15); }
}

@keyframes settleBump {
    0%   { transform: scale(1.12); }
    60%  { transform: scale(0.96); }
    100% { transform: scale(1); }
}

/* --- Dice Controls --- */
.dice-controls {
    display: flex;
    gap: 8px;
}

.roll-btn {
    background: linear-gradient(180deg, #3a4a2c 0%, #2c3a20 100%);
    color: #d8dcc8;
    border: 1px solid #4a6038;
    padding: 10px 30px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease-out;
    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    letter-spacing: 0.05em;
}

.roll-btn:hover:not(.btn-disabled) {
    background: linear-gradient(180deg, #4a5a34 0%, #3a4a28 100%);
    transform: translateY(-1px);
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.roll-btn:active:not(.btn-disabled) {
    transform: translateY(1px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.roll-btn.btn-disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.edit-btn {
    background: transparent;
    color: #6a5e4a;
    border: 1px solid #2a2218;
    padding: 10px 16px;
    font-size: 0.83rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.edit-btn:hover:not(.btn-disabled) {
    border-color: #3a3028;
    color: #9a8e7a;
}

.edit-btn.active {
    background: rgba(90, 138, 80, 0.08);
    border-color: #5a8a50;
    color: #5a8a50;
}

.edit-btn.btn-disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* =============================================
   Score Sheet — dark panel with brass rule
   ============================================= */
.score-sheet {
    width: 100%;
    background: #16120e;
    border: 1px solid #262018;
    border-top: 2px solid #382c1a;
    border-radius: 8px;
    padding: 2px 0;
}

.score-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.score-table th {
    text-align: center;
    padding: 7px 8px;
    color: #6a5e4a;
    font-weight: 500;
    border-bottom: 1px solid #262018;
    font-size: 0.78rem;
    letter-spacing: 0.03em;
}

.score-table th.cat-col { text-align: left; }

.score-table th.now-col { color: #c49a3c; }

.cat-row {
    transition: background 0.2s;
}

.cat-row td {
    padding: 6px 8px;
    border-bottom: 1px solid rgba(38, 32, 24, 0.6);
}

.cat-name {
    color: #8a7e6a;
    font-size: 0.8rem;
}

.score-val {
    text-align: center;
    font-variant-numeric: tabular-nums;
    color: #6a5e4a;
}

.score-val.scored {
    color: #c8bca4;
    font-weight: 600;
}

.score-val.empty {
    color: #2a2420;
}

.score-val.total {
    color: #c49a3c;
    font-weight: 700;
    font-size: 1rem;
}

/* --- Potential score badge --- */
.potential-cell { cursor: pointer; }

.potential-badge {
    display: inline-block;
    padding: 2px 10px;
    background: rgba(196, 154, 60, 0.08);
    border: 1px solid rgba(196, 154, 60, 0.2);
    border-radius: 4px;
    color: #c49a3c;
    font-weight: 600;
    transition: all 0.15s ease-out;
}

.potential-badge:hover {
    background: rgba(196, 154, 60, 0.18);
    border-color: rgba(196, 154, 60, 0.45);
    transform: scale(1.08);
}

.potential-badge.zero {
    color: #4a4438;
    background: rgba(74, 68, 56, 0.06);
    border-color: rgba(74, 68, 56, 0.15);
}

.potential-badge.zero:hover {
    background: rgba(74, 68, 56, 0.12);
    border-color: rgba(74, 68, 56, 0.3);
}

.cat-row.available {
    cursor: pointer;
}

.cat-row.available:hover {
    background: rgba(196, 154, 60, 0.1);
}

.cat-row.available:hover .cat-name {
    color: #c49a3c;
}

.cat-row.available:active {
    background: rgba(196, 154, 60, 0.18);
}

.cat-row.has-score .cat-name { color: #c8bca4; }

.section-sep td {
    padding: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, #302818, transparent);
    border: none;
}

.total-row td {
    border-top: 2px solid #302818;
    padding-top: 8px;
    border-bottom: none;
}

.cat-row.score-flash {
    animation: scoreFlash 0.8s ease-out;
}

@keyframes scoreFlash {
    0%   { background: rgba(196, 154, 60, 0.15); }
    100% { background: transparent; }
}

/* --- Upper subtotal & bonus rows --- */
.upper-subtotal {
    border-top: 1px solid #302818;
}

.upper-subtotal td {
    padding: 4px 8px;
    font-size: 0.75rem;
    border-bottom: none;
}

.upper-subtotal .cat-name {
    color: #6a5e4a;
}

.upper-subtotal .score-val {
    color: #6a5e4a;
    font-size: 0.75rem;
}

.bonus-row td {
    padding: 3px 8px;
    border-bottom: none;
    font-size: 0.75rem;
}

.bonus-row .cat-name {
    color: #6a5e4a;
}

.bonus-val {
    color: #c49a3c !important;
    font-weight: 700;
}

.bonus-need {
    color: #8a6a3a !important;
    font-size: 0.7rem !important;
}

.bonus-miss {
    color: #4a3828 !important;
}

.bonus-achieved .cat-name {
    color: #c49a3c;
}

.subtotal-row td {
    font-size: 0.85rem;
    color: #8a7e6a;
    border-bottom: 1px solid rgba(38, 32, 24, 0.4);
}

.section-sep-result td {
    padding: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, #302818, transparent);
}

/* =============================================
   Cut-in
   ============================================= */
.cutin {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    pointer-events: none;
    animation: cutinEnter 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.cutin::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 90px;
    transform: translateY(-50%);
    background: linear-gradient(90deg,
        transparent,
        rgba(15, 13, 10, 0.92) 15%,
        rgba(15, 13, 10, 0.92) 85%,
        transparent
    );
    border-top: 2px solid rgba(196, 154, 60, 0.6);
    border-bottom: 2px solid rgba(196, 154, 60, 0.6);
}

.cutin-text {
    position: relative;
    font-family: 'Shippori Mincho B1', serif;
    font-size: 2.2rem;
    font-weight: 800;
    color: #c49a3c;
    text-shadow: 0 0 20px rgba(196, 154, 60, 0.4),
                 0 2px 4px rgba(0, 0, 0, 0.6);
    letter-spacing: 0.15em;
}

.cutin-score {
    position: relative;
    font-size: 1rem;
    color: #8a7e6a;
    margin-top: 2px;
    letter-spacing: 0.08em;
}

.cutin-out {
    animation: cutinExit 0.3s ease-in both;
}

@keyframes cutinEnter {
    0% {
        opacity: 0;
    }
    30% {
        opacity: 1;
    }
    100% {
        opacity: 1;
    }
}

@keyframes cutinExit {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* --- Yacht special --- */
.cutin-yacht::before {
    height: 110px;
    background: linear-gradient(90deg,
        transparent,
        rgba(30, 20, 5, 0.95) 10%,
        rgba(30, 20, 5, 0.95) 90%,
        transparent
    );
    border-top: 3px solid #c49a3c;
    border-bottom: 3px solid #c49a3c;
    box-shadow: 0 0 40px rgba(196, 154, 60, 0.25);
}

.cutin-yacht .cutin-text {
    font-size: 3rem;
    color: #f0c848;
    text-shadow: 0 0 30px rgba(240, 200, 72, 0.5),
                 0 0 60px rgba(240, 200, 72, 0.2),
                 0 2px 4px rgba(0, 0, 0, 0.7);
    animation: yachtPulse 0.5s ease-in-out 2 alternate;
}

.cutin-yacht .cutin-score {
    font-size: 1.2rem;
    color: #c49a3c;
}

@keyframes yachtPulse {
    from { transform: scale(1); filter: brightness(1); }
    to   { transform: scale(1.06); filter: brightness(1.3); }
}

/* =============================================
   Analysis Panel
   ============================================= */
.analysis-panel {
    width: 100%;
    background: #12100c;
    border: 1px solid #262018;
    border-radius: 8px;
    overflow: hidden;
}

.analysis-panel.ai-thinking { opacity: 0.5; }

.analysis-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 14px;
    background: #16120e;
    border-bottom: 1px solid #262018;
}

.analysis-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: #8a7e6a;
    letter-spacing: 0.05em;
}

.analysis-note {
    font-size: 0.68rem;
    color: #504840;
}

.analysis-body {
    padding: 6px 10px;
    max-height: 340px;
    overflow-y: auto;
}

.analysis-body::-webkit-scrollbar { width: 4px; }
.analysis-body::-webkit-scrollbar-track { background: transparent; }
.analysis-body::-webkit-scrollbar-thumb {
    background: #2a2420;
    border-radius: 2px;
}

.analysis-loading {
    text-align: center;
    color: #6a5e4a;
    padding: 20px 16px;
    font-size: 0.82rem;
    letter-spacing: 0.05em;
    animation: loadPulse 1.4s ease-in-out infinite;
}

@keyframes loadPulse {
    0%, 100% { opacity: 0.4; }
    50%      { opacity: 1; }
}

.analysis-empty {
    text-align: center;
    color: #3a3428;
    padding: 12px;
    font-size: 0.82rem;
}

/* --- Analysis Table --- */
.analysis-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.76rem;
}

.analysis-table th {
    text-align: left;
    padding: 4px 6px;
    color: #504840;
    font-weight: 500;
    border-bottom: 1px solid #262018;
    font-size: 0.7rem;
    letter-spacing: 0.03em;
}

.analysis-table td {
    padding: 4px 6px;
    border-bottom: 1px solid rgba(38, 32, 24, 0.3);
}

.best-row {
    background: rgba(138, 170, 112, 0.05);
}

.best-row .a-cat {
    color: #8aaa70;
    font-weight: 600;
}

.a-cat { color: #8a7e6a; }

.a-score {
    font-variant-numeric: tabular-nums;
    color: #c8bca4;
    text-align: center;
}

.a-score.zero { color: #3a3428; }

.a-ev {
    font-variant-numeric: tabular-nums;
    color: #c49a3c;
    text-align: center;
    font-weight: 600;
}

.a-prob {
    color: #6a5e4a;
    text-align: center;
}

.a-hold {
    color: #5a5040;
    font-size: 0.7rem;
}

/* --- Bonus Tracker --- */
.bonus-tracker {
    margin-top: 10px;
    padding: 8px 10px;
    border-top: 1px solid #262018;
    font-size: 0.76rem;
}

.bonus-tracker.achieved {
    color: #c49a3c;
    font-weight: 600;
    text-align: center;
}

.bonus-tracker.missed {
    color: #4a3828;
    text-align: center;
}

.bt-title {
    color: #8a7e6a;
    font-size: 0.7rem;
    margin-bottom: 5px;
    letter-spacing: 0.05em;
}

.bt-bar-wrap {
    position: relative;
    height: 14px;
    background: #1a1610;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.bt-bar {
    height: 100%;
    background: linear-gradient(90deg, #6a4e1c, #c49a3c);
    border-radius: 3px;
    transition: width 0.4s ease-out;
}

.bt-bar-label {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    text-align: center;
    line-height: 14px;
    font-size: 0.65rem;
    color: #c8bca4;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

.bt-info {
    display: flex;
    justify-content: space-between;
    color: #6a5e4a;
    font-size: 0.7rem;
    margin-bottom: 4px;
}

.bt-info strong {
    color: #c49a3c;
}

.bt-detail {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 10px;
    margin-bottom: 4px;
}

.bt-cat {
    font-size: 0.65rem;
    color: #5a5040;
}

.bt-verdict {
    font-size: 0.72rem;
    font-weight: 600;
    margin-top: 3px;
}

.bt-verdict.good { color: #8aaa70; }
.bt-verdict.ok   { color: #c49a3c; }
.bt-verdict.warn { color: #b87830; }
.bt-verdict.bad  { color: #6a4838; }

/* =============================================
   Controls
   ============================================= */
.controls {
    display: flex;
    gap: 10px;
    width: 100%;
}

.ctrl-btn {
    flex: 1;
    padding: 10px;
    background: #16120e;
    border: 1px solid #262018;
    color: #6a5e4a;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.82rem;
    transition: all 0.2s;
    letter-spacing: 0.03em;
}

.ctrl-btn:hover {
    background: #1c1812;
    border-color: #3a3028;
    color: #c8bca4;
}

.ctrl-btn:active {
    transform: scale(0.97);
}

/* =============================================
   Result Screen
   ============================================= */
.result-screen {
    text-align: center;
    gap: 18px;
}

.result-title {
    font-family: 'Shippori Mincho B1', 'Yu Mincho', serif;
    font-size: 2.2rem;
    font-weight: 700;
    color: #c8bca4;
    letter-spacing: 0.15em;
    text-indent: 0.15em;
}

.result-title.win {
    color: #8aaa70;
    text-shadow: 0 0 30px rgba(138, 170, 112, 0.15);
}

.result-title.lose { color: #c07848; }
.result-title.draw { color: #c49a3c; }

.result-scores {
    display: flex;
    align-items: center;
    gap: 24px;
}

.result-score-box { text-align: center; }

.result-score-label {
    font-size: 0.82rem;
    color: #6a5e4a;
    margin-bottom: 6px;
    letter-spacing: 0.05em;
}

.result-score-value {
    font-family: 'Shippori Mincho B1', 'Yu Mincho', serif;
    font-size: 2.8rem;
    font-weight: 700;
    color: #c49a3c;
    line-height: 1;
}

.result-vs {
    font-size: 1.2rem;
    color: #2a2420;
    font-weight: 700;
}

.result-message {
    font-size: 0.88rem;
    color: #8a7e6a;
    max-width: 300px;
    line-height: 1.6;
}

/* --- Result Detail --- */
.result-detail {
    width: 100%;
    max-width: 360px;
    background: #16120e;
    border: 1px solid #262018;
    border-radius: 8px;
    padding: 4px 12px;
}

.result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.result-table th {
    text-align: center;
    padding: 6px 8px;
    color: #504840;
    font-weight: 500;
    border-bottom: 1px solid #262018;
    font-size: 0.72rem;
}

.result-table th:first-child { text-align: left; }

.result-table td {
    padding: 5px 8px;
    text-align: center;
    color: #8a7e6a;
    border-bottom: 1px solid rgba(38, 32, 24, 0.4);
    font-variant-numeric: tabular-nums;
}

.result-table td:first-child {
    text-align: left;
    color: #6a5e4a;
}

.result-table .total-row td {
    color: #c49a3c;
    font-weight: 700;
    border-top: 2px solid #302818;
    border-bottom: none;
    font-size: 0.9rem;
}

/* --- Share --- */
.share-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.share-label {
    font-size: 0.78rem;
    color: #3a3428;
}

.share-buttons {
    display: flex;
    gap: 8px;
}

.share-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid #262018;
    background: #16120e;
    color: #6a5e4a;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.share-btn:hover {
    background: #1c1812;
    border-color: #3a3028;
    color: #c8bca4;
}

.back-btn {
    background: none;
    border: 1px solid #262018;
    color: #6a5e4a;
    padding: 10px 32px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.88rem;
    transition: all 0.2s;
    letter-spacing: 0.03em;
}

.back-btn:hover {
    border-color: #3a3028;
    color: #a09080;
}

/* =============================================
   Custom Dialog
   ============================================= */
.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 6, 4, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: dialogFadeIn 0.15s ease-out;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

@keyframes dialogFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.dialog-box {
    background: #1a1612;
    border: 1px solid #302818;
    border-radius: 10px;
    padding: 28px 32px 22px;
    max-width: 320px;
    width: 90%;
    text-align: center;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(0, 0, 0, 0.2);
    animation: dialogSlideIn 0.15s ease-out;
}

@keyframes dialogSlideIn {
    from { transform: translateY(-12px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

.dialog-message {
    font-size: 0.92rem;
    color: #c8bca4;
    line-height: 1.65;
    margin-bottom: 20px;
}

.dialog-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.dialog-btn {
    padding: 9px 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.15s;
}

.dialog-cancel {
    background: transparent;
    border: 1px solid #262018;
    color: #6a5e4a;
}

.dialog-cancel:hover {
    border-color: #3a3028;
    color: #a09080;
}

.dialog-confirm {
    background: linear-gradient(180deg, #4a3820 0%, #3a2c18 100%);
    border: 1px solid #5a4830;
    color: #e8dcc4;
}

.dialog-confirm:hover {
    background: linear-gradient(180deg, #5a4828 0%, #4a3820 100%);
    border-color: #6a5838;
}

/* =============================================
   Ranking
   ============================================= */
.title-btn-row {
    display: flex;
    gap: 8px;
}

.ranking-section {
    width: 100%;
    max-width: 400px;
}

.ranking-heading {
    font-family: 'Shippori Mincho B1', 'Yu Mincho', serif;
    font-size: 1rem;
    color: #c49a3c;
    margin-bottom: 10px;
    letter-spacing: 0.1em;
    text-align: center;
}

.ranking-input {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 10px;
}

.ranking-name-input {
    width: 150px;
    padding: 8px 12px;
    background: #16120e;
    border: 1px solid #2a2218;
    color: #c8bca4;
    font-size: 0.85rem;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.2s;
}

.ranking-name-input:focus {
    border-color: #c49a3c;
}

.ranking-name-input::placeholder {
    color: #3a3428;
}

.ranking-submit-btn {
    padding: 8px 18px;
    background: linear-gradient(180deg, #4a3820 0%, #3a2c18 100%);
    color: #e8dcc4;
    border: 1px solid #5a4830;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.ranking-submit-btn:hover {
    background: linear-gradient(180deg, #5a4828 0%, #4a3820 100%);
    border-color: #6a5838;
}

.ranking-submit-btn.submitted {
    background: rgba(138, 170, 112, 0.12);
    border-color: rgba(138, 170, 112, 0.4);
    color: #8aaa70;
    cursor: default;
}

.ranking-tabs {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.ranking-tab {
    padding: 5px 10px;
    border: 1px solid #2a2218;
    background: transparent;
    color: #6a5e4a;
    font-size: 0.72rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.03em;
}

.ranking-tab:hover {
    border-color: #3a3028;
    color: #a09080;
}

.ranking-tab.active {
    background: #221e18;
    color: #c49a3c;
    font-weight: 600;
    border-color: #3a3028;
}

.ranking-table-wrap {
    max-height: 280px;
    overflow-y: auto;
    width: 100%;
}

.ranking-table-wrap::-webkit-scrollbar { width: 4px; }
.ranking-table-wrap::-webkit-scrollbar-track { background: transparent; }
.ranking-table-wrap::-webkit-scrollbar-thumb { background: #2a2420; border-radius: 2px; }

.ranking-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.ranking-table th {
    padding: 6px 8px;
    color: #504840;
    font-weight: 500;
    border-bottom: 1px solid #262018;
    font-size: 0.72rem;
    text-align: center;
    letter-spacing: 0.03em;
}

.ranking-table th:first-child { width: 28px; }

.ranking-table td {
    padding: 5px 8px;
    text-align: center;
    color: #8a7e6a;
    border-bottom: 1px solid rgba(38, 32, 24, 0.4);
    font-variant-numeric: tabular-nums;
}

.ranking-table td:nth-child(2) {
    text-align: left;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ranking-table tr.highlight td {
    color: #c49a3c;
    font-weight: 700;
}

.ranking-table tr.top1 td:first-child { color: #f0c848; }
.ranking-table tr.top2 td:first-child { color: #a8a8a8; }
.ranking-table tr.top3 td:first-child { color: #b87848; }

.ranking-loading {
    text-align: center;
    color: #3a3428;
    padding: 16px;
    font-size: 0.82rem;
}

/* =============================================
   Mobile
   ============================================= */
@media (max-width: 480px) {
    .game-title { font-size: 2.4rem; }

    .dice-tray {
        gap: 6px;
        padding: 16px 10px;
    }

    .die {
        width: 50px;
        height: 50px;
    }

    .game-header { padding: 6px 10px; }

    .turn-indicator {
        font-size: 0.8rem;
        padding: 3px 10px;
    }

    .round-info,
    .roll-info { font-size: 0.7rem; }

    .score-table { font-size: 0.78rem; }

    .score-table th,
    .score-table td { padding: 5px 4px; }

    .analysis-table { font-size: 0.7rem; }

    .analysis-body {
        max-height: 260px;
        padding: 4px 8px;
    }

    .controls { gap: 6px; }

    .ctrl-btn {
        padding: 8px;
        font-size: 0.78rem;
    }
}

@media (max-width: 360px) {
    .game-title { font-size: 2rem; }

    .die {
        width: 44px;
        height: 44px;
    }

    .dice-tray {
        gap: 4px;
        padding: 12px 8px;
    }

    .held-label { font-size: 0.5rem; }

    .roll-btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
}
