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

html, body {
    width: 100%;
    overflow-x: hidden;
    position: relative;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 5px;
    box-sizing: border-box;
}

.game-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    background-color: white;
    padding: 8px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    overflow-x: hidden;
}

.game-title {
    text-align: center;
    margin-bottom: 15px;
    padding: 10px 0;
}

.game-title h1 {
    font-size: clamp(20px, 5vw, 32px);
    color: #333;
    margin-bottom: 8px;
    font-weight: bold;
}

.game-title p {
    font-size: clamp(14px, 3.5vw, 18px);
    color: #666;
    margin: 0;
}

.variant-selector {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
    font-size: clamp(14px, 4vw, 18px);
}

.variant-selector label {
    margin-right: 10px;
    font-weight: bold;
}

.variant-selector select {
    padding: 8px 12px;
    font-size: clamp(14px, 4vw, 18px);
    border: 2px solid #4ecdc4;
    border-radius: 5px;
    background-color: white;
    cursor: pointer;
    min-width: 120px;
}

.variant-selector select:hover {
    border-color: #45b8b0;
}

.variant-selector select:focus {
    outline: none;
    border-color: #45b8b0;
    box-shadow: 0 0 5px rgba(78, 205, 196, 0.5);
}

.stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: clamp(14px, 4vw, 18px);
    font-weight: bold;
}

.energy {
    color: #ff6b6b;
}

.score {
    color: #4ecdc4;
}

.video-area {
    position: relative;
    width: 100%;
    max-width: 100%;
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    background-color: #000;
    border: 2px solid #333;
    overflow: hidden;
    max-height: calc(100vw - 20px);
}

.layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.layer1 {
    z-index: 1;
}

.layer2 {
    z-index: 2;
    pointer-events: none;
}

.layer3 {
    z-index: 3;
    pointer-events: none;
}

.loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    text-align: center;
    z-index: 4;
    flex-direction: column;
}

.loading-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: clamp(16px, 4vw, 22px);
    font-weight: bold;
}

.loading-submessage {
    font-size: clamp(14px, 3.5vw, 20px);
    font-weight: normal;
    opacity: 0.9;
    margin-top: 8px;
}

.loading-progress {
    font-size: clamp(18px, 5vw, 28px);
}

.transition-overlay .loading-content {
    font-size: clamp(18px, 5vw, 30px);
}

.drop-overlay .loading-content {
    font-size: clamp(20px, 5vw, 34px);
}

#hlsVideo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
}

#webpCanvas {
    width: 100%;
    height: 100%;
}

#arrow {
    width: auto;
    height: auto;
    max-width: 100px;
    position: absolute;
    transform: translate(-50%, -50%);
}

.info-area {
    min-height: 72px;
    max-height: 88px;
    height: 88px;
    margin: 10px 0;
    padding: 8px;
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: clamp(10px, 2.5vw, 12px);
    line-height: 1.2;
    white-space: pre-wrap;
    overflow-y: auto;
    box-sizing: border-box;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 10px;
    flex-wrap: wrap;
    width: 100%;
}

.controls button {
    padding: 20px 8px;
    font-size: clamp(11px, 2.5vw, 16px);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    background-color: #4ecdc4;
    color: white;
    transition: background-color 0.3s;
    flex: 1 1 calc(50% - 5px);
    min-width: 0;
    max-width: calc(50% - 5px);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    box-sizing: border-box;
}

.controls button:hover:not(:disabled) {
    background-color: #45b8b0;
}

.controls button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.game-hint {
    text-align: center;
    margin-top: 15px;
    margin-bottom: 10px;
    padding: 10px;
}

.game-hint p {
    font-size: clamp(12px, 3vw, 16px);
    color: #666;
    margin: 5px 0;
    line-height: 1.4;
}

.result-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    box-sizing: border-box;
}

.result-text {
    font-size: clamp(24px, 8vw, 48px);
    color: white;
    font-weight: bold;
    text-align: center;
    margin-bottom: 20px;
}

.result-score {
    font-size: clamp(18px, 6vw, 32px);
    color: white;
    text-align: center;
    margin-bottom: 20px;
}

.result-hint {
    font-size: clamp(14px, 4vw, 20px);
    color: white;
    text-align: center;
    margin-bottom: 30px;
}

.start-game-button {
    padding: 15px 30px;
    font-size: clamp(16px, 4vw, 24px);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    background-color: #4ecdc4;
    color: white;
    font-weight: bold;
    transition: background-color 0.3s;
    touch-action: manipulation;
    margin-bottom: 15px;
}

.start-game-button:last-child {
    margin-bottom: 0;
}

.start-game-button:hover {
    background-color: #45b8b0;
}

/* ポップアップのスタイル */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 20px;
    box-sizing: border-box;
}

.popup-content {
    background-color: white;
    border-radius: 10px;
    padding: 30px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.popup-content h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: clamp(20px, 5vw, 28px);
    text-align: center;
    color: #333;
}

.popup-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.popup-form label {
    font-size: clamp(14px, 3vw, 18px);
    font-weight: bold;
    color: #333;
}

.popup-form input[type="text"] {
    padding: 10px;
    font-size: clamp(14px, 3vw, 16px);
    border: 2px solid #ddd;
    border-radius: 5px;
    width: 100%;
    box-sizing: border-box;
}

.popup-form input[type="text"]:focus {
    outline: none;
    border-color: #4ecdc4;
}

.popup-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.popup-button {
    padding: 12px 20px;
    font-size: clamp(14px, 3vw, 18px);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    background-color: #4ecdc4;
    color: white;
    font-weight: bold;
    transition: background-color 0.3s;
    touch-action: manipulation;
}

.popup-button:hover {
    background-color: #45b8b0;
}

/* ランキングのスタイル */
.ranking-content {
    max-width: 600px;
}

.ranking-list {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.ranking-item {
    padding: 15px;
    margin-bottom: 10px;
    background-color: #f9f9f9;
    border-radius: 5px;
    border: 1px solid #ddd;
    font-size: clamp(14px, 3vw, 18px);
    white-space: nowrap;
    overflow-x: auto;
}

.popup-message {
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
    font-size: clamp(14px, 3vw, 16px);
    text-align: center;
    font-weight: bold;
}

.popup-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.popup-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

