/* --- 見た目 (CSS) --- */
@import url('https://fonts.googleapis.com/css2?family=Shippori+Mincho+B1:wght@800&display=swap');

body {
    background: #000;
    color: white;
    font-family: sans-serif;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* ライトモード用のスタイル定義 */
body.light-mode {
    background: #e0e0e0;
    color: #111;
}

header {
    width: 100%;
    height: 50px;
    background: #111;
    border-bottom: 2px solid #8a2be2;
    display: flex;
    align-items: center;
    padding: 0 10px;
    box-sizing: border-box;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.3s;
}

body.light-mode header {
    background: #f8f8f8;
    border-bottom: 2px solid #6b1fad;
}

.header-btn {
    background: #333;
    color: #ccc;
    border: 1px solid #555;
    padding: 5px 8px;
    font-size: 0.7rem;
    cursor: pointer;
    border-radius: 4px;
    white-space: nowrap;
    transition: all 0.2s;
}

body.light-mode .header-btn {
    background: #eee;
    color: #333;
    border-color: #ccc;
}

.btn-graph {
    background: #8a2be2;
    color: white;
    border-color: #a450ff;
}

body.light-mode .btn-graph {
    background: #6b1fad;
    border-color: #8a2be2;
    color: white;
}

.max-hamari-display {
    background: #000;
    color: #ff4444;
    border: 1px solid #ff4444;
    padding: 4px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
    font-weight: bold;
}

body.light-mode .max-hamari-display {
    background: #ffebee;
}

.main-content {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    box-sizing: border-box;
}

.machine {
    width: 100%;
    background: #111;
    border: 3px solid #8a2be2;
    border-radius: 15px;
    padding: 12px;
    position: relative;
    box-sizing: border-box;
    transition: background-color 0.3s, border-color 0.3s;
}

body.light-mode .machine {
    background: #f0f0f0;
    border-color: #6b1fad;
}

.screen {
    background: #000;
    height: 350px;
    border-radius: 10px;
    border: 2px solid #444;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    width: 100%;
}

/* 図柄表示部分 */
.digit-container {
    display: flex;
    gap: 8px;
}

.digit {
    font-size: 10.2rem;
    font-weight: 900;
    font-family: 'Shippori Mincho B1', serif;
    width: 112px;
    text-align: center;
}

.mode-display {
    position: absolute;
    bottom: 35px;
    right: 15px;
    color: #8a2be2;
    font-weight: bold;
    font-size: 0.9rem;
    background: rgba(0, 0, 0, 0.5);
    padding: 2px 6px;
    border-radius: 3px;
    border-right: 3px solid #8a2be2;
    text-align: right;
    min-width: 90px;
}

.gold {
    color: #ffeb3b;
    text-shadow: 0 0 30px #ffeb3b;
}

.odd {
    color: #ff4444;
    text-shadow: 0 0 20px #ff4444;
}

.even {
    color: #4444ff;
    text-shadow: 0 0 20px #4444ff;
}

.hidden-lamp {
    position: absolute;
    top: 12px;
    right: 20px;
    width: 15px;
    height: 15px;
    background: #222;
    border-radius: 50%;
    border: 1px solid #444;
}

.lamp-active {
    animation: rainbow-bg 0.3s infinite;
    box-shadow: 0 0 20px #fff;
}

@keyframes rainbow-bg {
    0% {
        background: #f00;
    }

    20% {
        background: #ff0;
    }

    40% {
        background: #0f0;
    }

    60% {
        background: #0ff;
    }

    80% {
        background: #00f;
    }

    100% {
        background: #f0f;
    }
}

.vibrate {
    animation: vibration 0.05s infinite;
}

.vibe-white {
    border-color: #ffffff !important;
    box-shadow: 0 0 30px #ffffff, inset 0 0 20px #ffffff !important;
}

.vibe-red {
    border-color: #ff0000 !important;
    box-shadow: 0 0 30px #ff0000, inset 0 0 20px #ff0000 !important;
}

.vibe-rainbow {
    animation: vibration 0.05s infinite, rainbow-border 0.2s infinite !important;
}

@keyframes vibration {
    0% {
        transform: translate(0, 0);
    }

    25% {
        transform: translate(-2px, 2px);
    }

    50% {
        transform: translate(2px, -2px);
    }

    75% {
        transform: translate(-2px, -2px);
    }

    100% {
        transform: translate(0, 0);
    }
}

/* 保留デザイン */
.heso-overlay {
    position: absolute;
    bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.heso-ball {
    width: 18px;
    height: 18px;
    background: #222;
    border-radius: 50%;
    border: 1px solid #555;
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
}

.heso-overlay.right-mode .heso-ball {
    border-radius: 2px !important;
    width: 16px;
    height: 16px;
}

.heso-overlay.right-mode {
    bottom: 80px;
    right: 10px;
    flex-direction: column-reverse;
    gap: 6px;
}

.heso-current {
    border-width: 2px !important;
    border-color: #fff !important;
}

.heso-red {
    background: radial-gradient(circle, #ff4444, #880000);
    box-shadow: 0 0 8px #ff0000;
    border-color: #f00;
}

.heso-green {
    background: radial-gradient(circle, #44ff44, #008800);
    box-shadow: 0 0 8px #00ff00;
    border-color: #0f0;
}

.heso-blue {
    background: radial-gradient(circle, #4444ff, #000088);
    box-shadow: 0 0 8px #0000ff;
    border-color: #00f;
}

.heso-rainbow {
    animation: rainbow-bg 0.5s infinite;
}

.heso-vibe {
    animation: vibration 0.1s infinite !important;
    background: radial-gradient(circle, #fff, #ff8c00) !important;
    box-shadow: 0 0 12px #ff8c00;
    border-color: #f00 !important;
}

@keyframes upgrade-flash {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.4);
        filter: brightness(1.5);
    }

    100% {
        transform: scale(1);
    }
}

.upgrade-anim {
    animation: upgrade-flash 0.4s ease-out;
}

/* Vストックのアニメーション */
.v-stock-anim {
    position: absolute;
    bottom: 60px;
    font-size: 4rem;
    font-weight: 900;
    font-family: 'Shippori Mincho B1', monospace;
    color: #fff;
    text-shadow: 0 0 10px #fff;
    animation: rainbow-color 1.5s infinite, v-pulse 0.5s infinite alternate;
    z-index: 10;
}

@keyframes rainbow-color {
    0% {
        color: #f00;
        text-shadow: 0 0 20px #f00;
    }

    20% {
        color: #ff0;
        text-shadow: 0 0 20px #ff0;
    }

    40% {
        color: #0f0;
        text-shadow: 0 0 20px #0f0;
    }

    60% {
        color: #0ff;
        text-shadow: 0 0 20px #0ff;
    }

    80% {
        color: #00f;
        text-shadow: 0 0 20px #00f;
    }

    100% {
        color: #f0f;
        text-shadow: 0 0 20px #f0f;
    }
}

@keyframes v-pulse {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.1);
    }
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    margin-top: 12px;
}

.stat-item {
    background: #000;
    border: 1px solid #333;
    padding: 5px 0;
    text-align: center;
    border-radius: 4px;
    transition: background-color 0.3s, border-color 0.3s;
}

body.light-mode .stat-item {
    background: #fdfdfd;
    border-color: #ccc;
}

.stat-val {
    font-size: 1.2rem;
    font-weight: bold;
    font-family: monospace;
    color: #fff;
    transition: color 0.3s;
}

body.light-mode .stat-val {
    color: #111;
}

.stat-label {
    font-size: 0.55rem;
    color: #888;
    display: block;
}

body.light-mode .stat-label {
    color: #666;
}

.control-panel {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    width: 100%;
    height: 65px;
}

.side-btns {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 55px;
}

.side-btn {
    flex: 1;
    background: #222;
    color: #666;
    border: 1px solid #444;
    font-size: 0.7rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

body.light-mode .side-btn {
    background: #ddd;
    color: #555;
    border-color: #bbb;
}

.side-btn.active {
    background: #8a2be2;
    color: #fff;
    border-color: #a450ff;
}

body.light-mode .side-btn.active {
    background: #6b1fad;
    color: #fff;
    border-color: #8a2be2;
}

.btn-auto {
    flex: 1;
    background: #8a2be2;
    color: white;
    border: 1px solid #a450ff;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

body.light-mode .btn-auto {
    background: #6b1fad;
    border-color: #8a2be2;
}

.btn-stop {
    background: #444 !important;
    border-color: #666 !important;
}

body.light-mode .btn-stop {
    background: #999 !important;
    border-color: #aaa !important;
}

/* 履歴表示部分 */
.log {
    width: 100%;
    max-width: 480px;
    height: 440px;
    background: #000;
    margin-top: 10px;
    padding: 10px;
    font-size: 0.91rem;
    color: #ffffff;
    overflow-y: auto;
    border: 1px solid #333;
    font-family: monospace;
    box-sizing: border-box;
    line-height: 1.5;
    transition: background-color 0.3s, border-color 0.3s, color 0.3s;
}

body.light-mode .log {
    background: #fff;
    color: #222;
    border-color: #ccc;
}

#modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

#modal-content {
    background: #eee;
    border: 2px solid #6b1fad;
    width: 92%;
    max-width: 450px;
    padding: 15px;
    border-radius: 12px;
    overflow-y: auto;
    max-height: 90vh;
    color: #111;
}

.graph-area {
    background: #fff;
    height: 200px;
    margin-bottom: 20px;
    border: 1px solid #ccc;
}

.effect-text {
    position: absolute;
    color: white;
    font-weight: bold;
    font-size: 2.2rem;
    z-index: 5;
    text-shadow: 0 0 10px #000;
    background: rgba(0, 0, 0, 0.7);
    padding: 5px 15px;
    border-radius: 5px;
    display: none;
    text-align: center;
}

/* PC向けレイアウト（横並び） */
@media (min-width: 768px) {
    .main-content {
        max-width: 900px;
        flex-direction: row-reverse;
        align-items: flex-start;
        justify-content: center;
        gap: 20px;
    }

    .machine {
        flex: 3;
        display: flex;
        flex-direction: column;
    }

    .log {
        flex: 2;
        margin-top: 0;
        height: 515px;
    }
}