body {
    font-family: 'Comic Sans MS', 'Rounded Mplus 1c', Arial, sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    height: 100vh;
    background-color: #f4f4f9;
    overflow: hidden; 
    user-select: none; 
    -webkit-user-select: none;
    touch-action: manipulation; 
}

/* Layout */
.left-panel {
    width: 66.66%;
    padding: 15px 20px;
    box-sizing: border-box;
    border-right: 2px solid #ddd;
    position: relative; 
    overflow: hidden; 
    background: radial-gradient(circle at center, #ffffff 0%, #eef2f3 100%);
}

.right-panel {
    width: 33.33%;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    background-color: #ffffff;
    z-index: 10; 
}

.right-section {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid #ddd;
    flex-direction: column;
    padding: 10px;
}

.right-section:last-child {
    border-bottom: none;
}

/* 100-Cell Math Styles */
.controls-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
    position: relative;
    z-index: 20; 
}

.controls-top {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.controls-bottom {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

button, select {
    padding: 8px 16px;
    font-size: 16px;
    cursor: pointer;
    border-radius: 8px;
    border: 1px solid #999;
    background-color: #fff;
}

button {
    background-color: #ff9800;
    color: white;
    font-weight: bold;
    border: none;
}

button:active {
    background-color: #e68a00;
}

.tip-text {
    font-size: 14px;
    color: #d84315;
    background: #ffecb3;
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.legend {
    font-size: 13px;
    background: #e3f2fd;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #90caf9;
    color: #0d47a1;
    font-weight: bold;
}

#score-display {
    font-size: 24px;
    font-weight: bold;
    color: #d32f2f;
    background: #fff;
    padding: 5px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border: 2px solid #ffc107;
    margin-left: auto;
}

#grid-container {
    position: relative;
    z-index: 5; 
}

table.math-grid {
    border-collapse: collapse;
    background-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    border-radius: 8px;
}

.math-grid th, .math-grid td {
    border: 1px solid #aaa;
    width: 48px;
    height: 38px;
    text-align: center;
    font-size: 18px;
}

.math-grid th {
    background-color: #bbdefb;
    font-weight: bold;
    color: #0d47a1;
}

.math-grid td input {
    width: 100%;
    height: 100%;
    border: none;
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    box-sizing: border-box;
    background-color: transparent;
    touch-action: manipulation; 
}

.math-grid td input:focus {
    outline: 3px solid #ff9800;
    background-color: white;
    z-index: 10;
    position: relative;
}

/* --- Physics & Interactive Elements --- */
#physics-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; 
    z-index: 10; 
}

.physics-ball {
    position: absolute;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #FF9800; 
    border: 2px solid #E65100;
    color: white;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    box-sizing: border-box;
    box-shadow: inset -3px -3px 6px rgba(0,0,0,0.3), 0 4px 6px rgba(0,0,0,0.4);
    pointer-events: none; 
}

.physics-stick {
    position: absolute;
    border-radius: 8px;
    pointer-events: auto; 
    cursor: grab; 
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    box-sizing: border-box;
    touch-action: none; 
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}
.physics-stick:active { cursor: grabbing; }

#spawn-box {
    position: absolute;
    top: 130px; 
    right: 30px;
    width: 80px;
    height: 60px;
    background: linear-gradient(to bottom, #2196F3, #1565C0);
    border: 3px solid #0D47A1;
    border-radius: 10px;
    color: white;
    font-weight: bold;
    font-size: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 15; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    pointer-events: auto;
    cursor: default;
    transition: all 0.3s;
}

#spawn-box.active {
    pointer-events: auto;
    cursor: pointer;
    background: linear-gradient(to bottom, #ff4081, #c2185b);
    border-color: #880e4f;
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 5px 15px rgba(255,64,129,0.3); }
    100% { transform: scale(1.1); box-shadow: 0 5px 25px rgba(255,64,129,0.7); }
}

#spawn-box::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 10px;
    background-color: #333;
    border-radius: 0 0 5px 5px;
}

/* --- ギミック棒置き場（ストレージ） --- */
#stick-storage-zone {
    position: absolute;
    top: 300px;
    right: 20px;
    width: 130px;
    height: calc(100% - 330px);
    min-height: 200px;
    background-color: rgba(230, 240, 250, 0.6);
    border: 2px dashed #90caf9;
    border-radius: 10px;
    color: #1565c0;
    font-weight: bold;
    display: flex;
    justify-content: center;
    padding-top: 10px;
    box-sizing: border-box;
    z-index: 2;
    pointer-events: none; 
}

#goal-zone {
    position: absolute;
    bottom: 30px;
    left: 30px;
    width: 140px;
    height: 60px;
    background-color: rgba(0,0,0,0.8);
    border: 4px solid #FFEB3B;
    border-top: none; 
    border-radius: 5px 5px 30px 30px; 
    box-shadow: 0 10px 20px rgba(0,0,0,0.3), inset 0 0 15px #FF9800;
    color: #FFEB3B;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 10px;
    box-sizing: border-box;
    font-size: 20px;
    text-shadow: 0 0 5px #FFEB3B;
    z-index: 1; 
}

/* Digital Clock & Calendar Styles */
#digital-clock { font-size: 3rem; font-weight: bold; color: #333; }
.calendar-container { width: 100%; max-width: 250px; text-align: center; }
.calendar-header { font-weight: bold; margin-bottom: 10px; font-size: 1.2rem; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.calendar-day-name { font-weight: bold; font-size: 0.9rem; color: #666; }
.calendar-day { padding: 5px; font-size: 0.9rem; background: #f9f9f9; }
.calendar-day.today { background: #4CAF50; color: white; border-radius: 3px; font-weight: bold; }