:root {
    --primary-color: #4facfe;
    --danger-color: #ff6b6b;
    --warning-color: #feca57;
    --success-color: #1dd1a1;
    --text-color: #333;
    --water-color: rgba(79, 172, 254, 0.7);
    --font-heading: 'Noto Sans JP', sans-serif;
    --font-body: 'Noto Sans JP', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
}

body {
    font-family: var(--font-body);
    background-color: #81ecec;
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-container {
    width: 100%;
    max-width: 800px;
    height: 100vh;
    max-height: 600px;
    background: #fff;
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border-radius: 30px;
    overflow: hidden;
    background-image: url('Asset/bg.png');
    background-size: cover;
    background-position: center;
    border: 8px solid #fff;
}

/* Header */
.game-header {
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    z-index: 20;
}

.game-header h1 {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--primary-color);
    text-shadow: 2px 2px 0 #fff;
}

.score-board {
    font-family: monospace;
    font-size: 1.2rem;
    font-weight: bold;
    color: #555;
    background: #f1f2f6;
    padding: 5px 15px;
    border-radius: 10px;
}

/* Main View */
.game-view {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.scene-layer {
    width: 100%;
    height: 100%;
    position: relative;
    background: transparent;
}

/* Discharge Background Overlay */
.discharge-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('Asset/bg2.png');
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
    pointer-events: none;
}

/* 水位表示コンテナ：画像の貯水池エリア（左側）に合わせる */
.water-container {
    position: absolute;
    bottom: 0;
    left: 0;
    /* 少し幅を広げて調整 */
    width: 49.5%;
    height: 75%;
    z-index: 1;
    mix-blend-mode: multiply;
    opacity: 0.8;
    /* 下半分は垂直、上部は2段階で広がっていく形状 
       (0,0)左上 -> (100%,0)右上 -> (78%,28%)屈折2(72%高さ) -> (70%,40%)屈折1(60%高さ) -> (70%,100%)右下 -> (0,100%)左下
    */
    clip-path: polygon(0 0, 100% 0, 78% 28%, 70% 40%, 70% 100%, 0 100%);
}

.water-surface {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: var(--primary-color);
    transition: height 0.05s linear;
    border-top: 3px solid rgba(255, 255, 255, 0.5);
}

.dam-structure {
    display: none;
}

/* Weather */
.weather-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.game-container.raining .weather-layer {
    background: rgba(0, 0, 0, 0.1);
}

/* Status Indicators */
.status-indicators {
    position: absolute;
    top: 90px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 10;
    width: 180px;
}

.indicator {
    background: rgba(255, 255, 255, 0.9);
    padding: 10px;
    border-radius: 15px;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.05);
}

.indicator label {
    font-size: 0.8rem;
    color: #555;
    font-weight: 700;
    display: block;
    margin-bottom: 5px;
}

.bar-container {
    width: 100%;
    height: 15px;
    background: #dfe6e9;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid #fff;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1);
}

.bar-fill {
    height: 100%;
    width: 100%;
    transition: width 0.2s;
}

#dam-health-bar {
    background-color: var(--success-color);
}

#flood-risk-bar {
    background-color: var(--warning-color);
    width: 0%;
}

/* Control Panel */
.control-panel {
    background: #fff;
    padding: 1.5rem;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-top: 5px solid #74b9ff;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    background: #f1f2f6;
    padding: 15px;
    border-radius: 20px;
}

.control-group label {
    font-weight: 900;
    font-size: 1.2rem;
    color: var(--primary-color);
    white-space: nowrap;
}

input[type=range] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 35px;
    width: 35px;
    border-radius: 50%;
    background: #ff9f43;
    cursor: pointer;
    margin-top: -14px;
    box-shadow: 0 4px 0 #e58e26;
    border: 4px solid #fff;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 10px;
    background: #dfe6e9;
    border-radius: 5px;
}

.info-group {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding-top: 10px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 1rem;
    font-weight: 900;
    color: #636e72;
    background: #f8f9fa;
    padding: 8px 20px;
    border-radius: 50px;
    border: 2px solid #dfe6e9;
}

/* Overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    text-align: center;
    color: #333;
    padding: 3rem;
    max-width: 80%;
    background: #fff;
    border-radius: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: 5px solid var(--primary-color);
}

.modal h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.tutorial {
    margin-bottom: 2rem;
    line-height: 1.8;
    color: #555;
    font-size: 1.1rem;
}

.primary-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem 3rem;
    font-size: 1.2rem;
    font-weight: 900;
    border-radius: 50px;
    cursor: pointer;
    font-family: var(--font-body);
    box-shadow: 0 6px 0 #2e86de;
    transition: transform 0.1s, box-shadow 0.1s;
}

.primary-btn:hover {
    transform: translateY(2px);
    box-shadow: 0 4px 0 #2e86de;
}

.primary-btn:active {
    transform: translateY(6px);
    box-shadow: none;
}