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

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-container {
    width: 100%;
    /* 1인용 기준 기본 최대폭 */
    max-width: 1200px;
    height: 100vh;
    max-height: 900px;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    transition: max-width 0.3s ease;
}

.game-container.wide-mode {
    max-width: 98vw;
}

header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.6);
    position: relative;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    z-index: 10;
}

.header-actions {
    position: absolute;
    left: 20px;
    display: flex;
    gap: 10px;
}

.action-btn {
    text-decoration: none;
    color: #555;
    font-size: 0.9rem;
    font-weight: bold;
    background: rgba(255,255,255,0.8);
    padding: 6px 12px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.action-btn:hover { background: white; }

.header-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

h1 {
    font-size: 1.6rem;
    color: #333;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
}

#game-main-area {
    flex-grow: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#boards-container {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.player-board {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    border-right: 2px dashed rgba(0,0,0,0.15);
    overflow: hidden;
}
.player-board:last-child {
    border-right: none;
}

.board-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: rgba(255,255,255,0.3);
    font-weight: bold;
    color: #444;
}
.player-score {
    background: white;
    padding: 4px 10px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.board-play-area {
    flex-grow: 1;
    position: relative;
}

.board-bins {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    padding: 8px 4px;
    height: 120px;
    background: rgba(255, 255, 255, 0.4);
}

.player-board.multi .bin-label { font-size: 0.7rem; }
.player-board.multi .bin-icon { font-size: 1.5rem; }

.bin {
    width: 18%;
    height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    border-radius: 8px;
    padding-bottom: 5px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    position: relative;
}

.bin.highlight {
    transform: scale(1.05) translateY(-5px);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
}

.bin[data-type="general"] { background: linear-gradient(to bottom, #dcdcdc, #a9a9a9); }
.bin[data-type="plastic"] { background: linear-gradient(to bottom, #e0f7fa, #80deea); }
.bin[data-type="can"] { background: linear-gradient(to bottom, #fff9c4, #fff59d); }
.bin[data-type="paper"] { background: linear-gradient(to bottom, #e8f5e9, #a5d6a7); }
.bin[data-type="glass"] { background: linear-gradient(to bottom, #ffe0b2, #ffb74d); }

.bin-label {
    font-size: 0.8rem;
    font-weight: bold;
    text-align: center;
    color: #333;
    margin-bottom: 3px;
    z-index: 2;
    background: rgba(255,255,255,0.7);
    padding: 2px 4px;
    border-radius: 5px;
    word-break: keep-all;
}

.bin-icon {
    font-size: 1.8rem;
    margin-bottom: 5px;
    z-index: 2;
}

.item {
    position: absolute;
    font-size: 3.5rem;
    cursor: grab;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
    transition: transform 0.1s;
    touch-action: none;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
    z-index: 10;
}
.player-board.multi .item { font-size: 2.5rem; }

.item:active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.1) rotate(calc(var(--rot, 0deg) + 5deg)) !important;
}

.wrong-animation { animation: shake 0.5s; }
@keyframes shake {
    0% { transform: translate(-50%, -50%) translateX(0); }
    25% { transform: translate(-50%, -50%) translateX(-15px); }
    50% { transform: translate(-50%, -50%) translateX(15px); }
    75% { transform: translate(-50%, -50%) translateX(-15px); }
    100% { transform: translate(-50%, -50%) translateX(0); }
}

.feedback-mark {
    position: absolute;
    font-size: 5rem;
    font-weight: bold;
    z-index: 150;
    pointer-events: none;
    transform: translate(-50%, -50%);
    animation: popInOut 0.8s forwards;
    text-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
.feedback-mark.correct { color: #4caf50; }
.feedback-mark.wrong { color: #f44336; }

@keyframes popInOut {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    40% { transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
}

.overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.85);
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    z-index: 200;
    backdrop-filter: blur(5px);
    transition: opacity 0.3s ease;
}
.overlay h2 { font-size: 2rem; color: #333; margin-bottom: 15px; text-align: center; }
.overlay p { font-size: 1.1rem; color: #666; margin-bottom: 30px; text-align: center; }
.overlay.hidden { display: none; opacity: 0; }

.board-completed-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.6);
    display: flex; justify-content: center; align-items: center;
    z-index: 150;
}
.board-completed-overlay h3 {
    font-size: 3rem;
    color: #4caf50;
    text-shadow: 2px 2px 5px rgba(255,255,255,0.8);
    background: rgba(255,255,255,0.9);
    padding: 10px 30px;
    border-radius: 20px;
}
.board-completed-overlay.hidden { display: none; }

.start-btn {
    padding: 10px 20px; font-size: 1.2rem; font-weight: bold; color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none; border-radius: 20px; cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2); transition: transform 0.2s;
}
.start-btn:hover { transform: scale(1.05); }

.ranking-item {
    display: flex; justify-content: space-between; align-items: center;
    background: rgba(255,255,255,0.9); padding: 10px 15px; margin-bottom: 8px;
    border-radius: 10px; font-size: 1.2rem; font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

@media (max-width: 768px) {
    .player-board.multi .item { font-size: 2rem; }
    .player-board.multi .bin { height: 75px; max-height: 75px; }
    .player-board.multi .bin-label { font-size: 0.6rem; margin-bottom: 1px; padding: 1px 2px; }
    .player-board.multi .bin-icon { font-size: 1.2rem; margin-bottom: 2px;}
    .board-header { padding: 5px; font-size: 0.8rem; }
}

@media (max-width: 400px) {
    .header-actions { position: relative; left: 0; margin-bottom: 10px; justify-content: center; width: 100%; }
    header { flex-direction: column; }
}
