:root {
    /* Color Palette - Coal Mine Theme */
    --bg-color: #120e0c;
    /* Deep dirt brown */
    --bg-gradient: radial-gradient(circle at center, #2b221d 0%, #120e0c 100%);
    --panel-bg: rgba(43, 30, 24, 0.85);
    /* Wooden/rusty panel background */
    --panel-border: rgba(184, 115, 51, 0.4);
    /* Copper/rust colored border */

    --text-main: #f0e6d2;
    /* Dusty parchment white */
    --text-light: #a39587;
    /* Ashy gray-brown */

    --accent-color: #fbbf24;
    /* Gold ore */
    --accent-hover: #fcd34d;
    --danger-color: #ef4444;
    /* Bright red for danger */
    --danger-hover: #f87171;
    --success-color: #10b981;
    /* Green for safe */

    --card-1pt: #3b82f6;
    --card-2pt: #8b5cf6;
    --card-3pt: #f59e0b;
    --card-crack: #dc2626;
    /* Deeper red */
    --card-special: #db2777;
    /* Deep pink/magenta */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background: var(--bg-gradient);
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

h1,
h2,
h3,
.game-title {
    font-family: 'Shippori Mincho', serif;
}

#app,
#shake-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
}


.container {
    width: 100%;
    max-width: 900px;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.hidden {
    display: none !important;
}

/* Panels (Wood/Metal style) */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 2px solid var(--panel-border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8), 0 10px 30px rgba(0, 0, 0, 0.8);
}

/* Buttons */
.btn {
    display: block;
    width: 100%;
    padding: 14px;
    font-size: 1.1rem;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    margin-bottom: 12px;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.primary-btn {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #2b1d0f;
    box-shadow: 0 4px 15px rgba(217, 119, 6, 0.4);
    border: 1px solid #fbbf24;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.3);
}

.primary-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    box-shadow: 0 6px 20px rgba(217, 119, 6, 0.6);
}

.secondary-btn {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border: 1px solid var(--panel-border);
}

.secondary-btn:hover:not(:disabled) {
    background-color: rgba(255, 255, 255, 0.2);
}

.danger-btn {
    background-color: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.5);
}

.danger-btn:hover:not(:disabled) {
    background-color: rgba(239, 68, 68, 0.3);
}

.text-btn {
    background: transparent;
    color: var(--text-light);
    text-decoration: underline;
    font-size: 0.9rem;
}

.text-btn:hover {
    color: var(--text-main);
}

/* Inputs */
.input-group {
    margin-bottom: 24px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-light);
    font-size: 0.9rem;
}

.input-group input {
    width: 100%;
    padding: 14px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.input-group input:focus {
    border-color: var(--accent-color);
}

/* Screens */
.screen {
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.title-logo {
    text-align: center;
    margin-bottom: 40px;
    margin-top: 20px;
}

.game-title {
    font-size: 2.5rem;
    color: var(--accent-color);
    text-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
    margin-bottom: 5px;
}

/* ルール画面 */
.rule-section {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.rule-section h3 {
    color: var(--accent-color);
    margin-top: 0;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 5px;
}

.rule-section p,
.rule-section ul {
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.5;
}

.rule-section ul {
    padding-left: 20px;
    margin: 10px 0;
}

.special-card-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rule-sp-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.rule-sp-desc {
    font-size: 0.85rem;
    line-height: 1.4;
    flex: 1;
}

/* ラウンド開始アニメーション */
#round-start-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    z-index: 2000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
}

#round-start-overlay:not(.hidden) {
    display: flex !important;
    animation: fadeInOut 3s forwards;
}

#round-start-title {
    font-size: 3.5rem;
    color: var(--accent-color);
    margin-bottom: 10px;
    text-shadow: 0 0 20px rgba(245, 158, 11, 0.8);
}

.round-subtitle {
    font-size: 1.5rem;
    margin-bottom: 40px;
    font-weight: bold;
    color: var(--danger-color);
}

.adding-cards-animation {
    display: flex;
    gap: 30px;
}

.anim-card {
    width: 100px;
    height: 150px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1.2rem;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
    border: 3px solid var(--panel-border);
    animation: dropIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

.adding-cards-animation .anim-card:nth-child(1) {
    animation-delay: 0.5s;
}

.adding-cards-animation .anim-card:nth-child(2) {
    animation-delay: 1.0s;
}

@keyframes dropIn {
    0% {
        transform: translateY(-150px) rotate(-15deg) scale(0);
        opacity: 0;
    }

    100% {
        transform: translateY(0) rotate(0) scale(1);
        opacity: 1;
    }
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    85% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-light);
}

.screen-heading {
    font-size: 1.8rem;
    text-align: center;
    margin-bottom: 24px;
    color: var(--accent-color);
}

/* Lobby */
.room-info-card {
    text-align: center;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    margin-bottom: 20px;
}

.styled-list {
    list-style: none;
}

.styled-list li {
    padding: 10px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.styled-list li:last-child {
    border-bottom: none;
}

/* Game Screen */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.round-indicator {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 20px;
}

.status-bars {
    display: flex;
    gap: 15px;
}

.pool-container,
.crack-container,
.deck-container {
    background: var(--panel-bg);
    padding: 8px 15px;
    border-radius: 8px;
    border: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.pool-container .label,
.crack-container .label,
.deck-container .label {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 4px;
}

.pool-container .value,
.deck-container .value {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--accent-color);
    text-shadow: 0 0 5px rgba(245, 158, 11, 0.5);
}

.prob-text {
    font-size: 0.8rem;
    font-weight: bold;
    margin-top: 2px;
    transition: color 0.3s;
}

.crack-gauge {
    display: flex;
    gap: 4px;
    margin-top: 5px;
}

.crack-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
}

.crack-dot.filled {
    background: var(--danger-color);
    box-shadow: 0 0 8px var(--danger-color);
}

.crack-dot.threshold {
    border: 2px solid var(--danger-color);
}

/* Board */
.game-board {
    min-height: 250px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.board-msg {
    font-size: 1.1rem;
    margin-bottom: 20px;
    text-align: center;
    min-height: 28px;
}

.cards-area {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    width: 100%;
}

.playing-card {
    width: 150px;
    height: 215px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    animation: cardAppear 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: transparent;
}

.crack-glow {
    animation: dangerPulse 1.5s infinite alternate;
}

@keyframes dangerPulse {
    0% {
        box-shadow: 0 0 10px rgba(220, 38, 38, 0.5);
    }

    100% {
        box-shadow: 0 0 30px rgba(220, 38, 38, 1), 0 0 10px rgba(220, 38, 38, 0.8) inset;
    }
}

@keyframes cardAppear {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(50px) rotate(-10deg);
    }

    100% {
        opacity: 1;
        transform: scale(1) translateY(0) rotate(0);
    }
}

/* Player Status Area */
.player-status-area {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.player-card {
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid var(--panel-border);
    border-radius: 6px;
    padding: 10px;
    text-align: center;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
}

.player-card.active {
    border-color: rgba(255, 255, 255, 0.3);
}

.player-card.returned {
    opacity: 0.5;
    background: rgba(16, 185, 129, 0.1);
}

.player-card.ready {
    border-color: var(--success-color);
}

.p-name {
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-title {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: bold;
    color: #ffd700;
    background: rgba(255, 215, 0, 0.15);
    border: 1px solid rgba(255, 215, 0, 0.5);
    border-radius: 4px;
    padding: 2px 6px;
    margin-right: 5px;
    vertical-align: middle;
}

.game-over-container {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    max-width: 1100px;
    padding: 20px;
    box-sizing: border-box;
}

.titles-column {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
    max-width: 280px;
}

.title-box {
    background: var(--bg-card);
    border: 2px solid #ffd700;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(255,215,0,0.2);
    text-align: center;
}

.title-box-name {
    font-size: 1.15rem;
    font-weight: bold;
    color: #ffd700;
    margin-bottom: 5px;
}

.title-box-desc {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 10px;
    line-height: 1.3;
}

.title-box-players {
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--text-main);
}

.p-score {
    font-size: 1.2rem;
    color: var(--accent-color);
    font-weight: 900;
}

.p-status {
    font-size: 0.7rem;
    color: var(--text-light);
    margin-top: 5px;
}

/* Actions */
.action-area {
    display: flex;
    gap: 15px;
}

.img-action-btn {
    flex: 1;
    position: relative;
    padding: 0;
    height: 120px;
    border: 2px solid var(--panel-border);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: #000;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.img-action-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.5);
}

.img-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(100%);
}

.action-bg-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.img-action-btn:hover:not(:disabled) .action-bg-img {
    opacity: 0.8;
}

.action-btn-text {
    position: relative;
    z-index: 10;
    color: white;
    font-size: 1.5rem;
    font-weight: 900;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8), -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

.action-btn {
    flex: 1;
    padding: 20px;
    font-size: 1.2rem;
}

.dig-btn {
    background: linear-gradient(to bottom, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.dig-btn:hover:not(:disabled) {
    background: linear-gradient(to bottom, #f87171, #ef4444);
}

.return-btn {
    background: linear-gradient(to bottom, #10b981, #059669);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.return-btn:hover:not(:disabled) {
    background: linear-gradient(to bottom, #34d399, #10b981);
}

.waiting-text {
    text-align: center;
    color: var(--accent-color);
    font-weight: bold;
    animation: pulse 1.5s infinite;
    padding: 20px;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.5;
    }
}

/* Screen Shake Animation */
.shake {
    animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-2px, 2px, 0);
    }

    20%,
    80% {
        transform: translate3d(4px, -3px, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-6px, 4px, 0);
    }

    40%,
    60% {
        transform: translate3d(6px, -4px, 0);
    }
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    width: 90%;
    max-width: 400px;
    text-align: center;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

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

.modal-content h2 {
    margin-bottom: 20px;
    color: var(--accent-color);
}

.modal-body {
    margin-bottom: 25px;
    line-height: 1.5;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2000;
}

.toast {
    background: rgba(0, 0, 0, 0.8);
    border-left: 4px solid var(--accent-color);
    color: white;
    padding: 12px 20px;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: slideInRight 0.3s ease-out forwards, fadeOut 0.3s ease-in 2.7s forwards;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        display: none;
    }
}

/* Utilities */
.mt-1 {
    margin-top: 10px;
}

.mt-2 {
    margin-top: 20px;
}

/* Volume Controls */
#volume-control-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid #546e7a;
    border-radius: 25px;
    padding: 10px;
    display: flex;
    align-items: center;
    z-index: 2000;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    overflow: hidden;
    width: 45px;
    height: 45px;
    box-sizing: border-box;
}
#volume-control-container:hover {
    width: 210px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.85);
    padding: 10px 15px;
}
#volume-icon {
    font-size: 1.2rem;
    cursor: pointer;
    min-width: 25px;
    text-align: center;
    margin-right: 10px;
}
#volume-sliders {
    display: flex;
    flex-direction: column;
    opacity: 0;
    width: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    white-space: nowrap;
}
#volume-control-container:hover #volume-sliders {
    opacity: 1;
    width: 170px;
    pointer-events: auto;
}

@media (max-width: 800px) {
    .game-over-container {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
    
    .titles-column {
        width: 100%;
        max-width: 400px;
        order: 2;
    }
    
    .game-over-container .modal-content {
        order: 1;
        margin: 0 !important;
        width: 100%;
    }
}