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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #1a1a2e;
    color: #eee;
    min-height: 100vh;
    overflow-x: hidden;
}

#app {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.phase {
    display: none;
}

.phase.active {
    display: block;
}

.home-btn {
    position: fixed;
    top: 19px;
    left: 15px;
    z-index: 100;
    padding: 6px 12px;
    border: none;
    border-radius: 8px;
    background: rgba(0,0,0,0.3);
    color: #aaa;
    text-decoration: none;
    font-size: 0.85em;
    transition: all 0.2s;
}

.home-btn:hover {
    background: rgba(233, 69, 96, 0.15);
    color: #e94560;
}

/* Language Toggle */
.lang-toggle {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 100;
    display: flex;
    gap: 4px;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 4px;
}

.lang-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #aaa;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.lang-btn.active {
    background: #e94560;
    color: white;
}

/* Title */
.title {
    text-align: center;
    font-size: 2.2em;
    margin: 30px 0 10px;
    color: #e94560;
}

.subtitle {
    text-align: center;
    color: #888;
    margin-bottom: 30px;
    font-size: 1.1em;
}

/* Player Select */
.player-select {
    text-align: center;
    margin: 20px 0;
}

.player-select label {
    font-size: 1.1em;
    margin-right: 10px;
}

.player-buttons {
    display: inline-flex;
    gap: 8px;
    margin-top: 8px;
}

.player-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid #444;
    background: transparent;
    color: #eee;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.2s;
}

.player-btn:hover {
    border-color: #e94560;
}

.player-btn.active {
    background: #e94560;
    border-color: #e94560;
    color: white;
}

/* Role Grid */
.role-info {
    text-align: center;
    margin: 15px 0;
    color: #aaa;
}

.role-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin: 20px 0;
}

.role-card {
    background: #16213e;
    border: 2px solid #333;
    border-radius: 12px;
    padding: 15px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.role-card.team-werewolf-card {
    background: linear-gradient(135deg, #1a1a2e 60%, #2d1520);
    border-color: #4a2030;
}

.role-card.team-village-card {
    background: linear-gradient(135deg, #1a1a2e 60%, #152d1a);
    border-color: #204a2a;
}

.role-card.team-tanner-card {
    background: linear-gradient(135deg, #1a1a2e 60%, #2d2a15);
    border-color: #4a4020;
}

.role-card.team-variable-card {
    background: linear-gradient(135deg, #1a1a2e 60%, #201530);
    border-color: #3a2050;
}

.role-card:hover {
    transform: translateY(-2px);
}

.role-card.team-werewolf-card:hover { border-color: #ff6b6b; }
.role-card.team-village-card:hover { border-color: #51cf66; }
.role-card.team-tanner-card:hover { border-color: #ffd43b; }
.role-card.team-variable-card:hover { border-color: #9775fa; }

.role-card.selected {
    box-shadow: 0 0 15px rgba(233, 69, 96, 0.3);
}

.role-card.selected.team-werewolf-card {
    border-color: #ff6b6b;
    box-shadow: 0 0 15px rgba(255, 107, 107, 0.3);
}

.role-card.selected.team-village-card {
    border-color: #51cf66;
    box-shadow: 0 0 15px rgba(81, 207, 102, 0.3);
}

.role-card.selected.team-tanner-card {
    border-color: #ffd43b;
    box-shadow: 0 0 15px rgba(255, 212, 59, 0.3);
}

.role-card.selected.team-variable-card {
    border-color: #9775fa;
    box-shadow: 0 0 15px rgba(151, 117, 250, 0.3);
}

.role-card .role-icon {
    margin-bottom: 8px;
}

.role-card .role-icon {
    margin-bottom: 8px;
}

.role-card .role-icon img {
    width: 80px;
    height: 110px;
    object-fit: contain;
    border-radius: 8px;
}

.hide-card-names .role-card .role-icon img {
    object-fit: cover;
    object-position: center bottom;
    height: 95px;
}

.role-card .role-name {
    font-size: 0.95em;
    font-weight: 600;
}

.role-card .role-team {
    font-size: 0.75em;
    color: #888;
    margin-top: 4px;
}

.role-card .role-count {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #e94560;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    font-weight: bold;
}

.role-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #0f3460;
    border: 1px solid #e94560;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.8em;
    line-height: 1.4;
    color: #ddd;
    width: 220px;
    text-align: left;
    z-index: 50;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.role-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #0f3460;
}

.role-card:hover .role-tooltip {
    display: block;
}

.team-werewolf { color: #ff6b6b; }
.team-village { color: #51cf66; }
.team-tanner { color: #ffd43b; }
.team-variable { color: #9775fa; }

/* Selected Summary */
.selected-summary {
    text-align: center;
    margin: 15px 0;
    font-size: 1.1em;
}

.card-name-toggle {
    text-align: center;
    margin: 15px 0;
}

.card-name-toggle label {
    cursor: pointer;
    font-size: 0.95em;
    color: #aaa;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.card-name-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #e94560;
}

.music-select {
    text-align: center;
    margin: 20px 0;
}

.music-select label {
    font-size: 1.1em;
    display: block;
    margin-bottom: 8px;
}

.music-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

#music-dropdown {
    padding: 8px 14px;
    border-radius: 8px;
    border: 2px solid #444;
    background: #16213e;
    color: #eee;
    font-size: 0.95em;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

#music-dropdown:hover,
#music-dropdown:focus {
    border-color: #e94560;
}

.music-preview-btn {
    padding: 8px 14px;
    border: 1px solid #666;
    border-radius: 15px;
    background: transparent;
    color: #aaa;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s;
}

.music-preview-btn:hover {
    border-color: #e94560;
    color: #eee;
}

.speed-select {
    text-align: center;
    margin: 20px 0;
}

.speed-select label {
    font-size: 1.1em;
    margin-right: 10px;
}

.speed-buttons {
    display: inline-flex;
    gap: 8px;
    margin-top: 8px;
}

.speed-btn {
    padding: 8px 18px;
    border-radius: 20px;
    border: 2px solid #444;
    background: transparent;
    color: #eee;
    font-size: 0.95em;
    cursor: pointer;
    transition: all 0.2s;
}

.speed-btn:hover {
    border-color: #e94560;
}

.speed-btn.active {
    background: #e94560;
    border-color: #e94560;
    color: white;
}

.speed-hint {
    display: block;
    margin-top: 8px;
    font-size: 0.85em;
    color: #888;
}

.role-warning {
    text-align: center;
    color: #ffd43b;
    font-size: 0.9em;
    margin: 10px 0;
}

/* Buttons */
.btn-primary {
    display: block;
    width: 100%;
    max-width: 400px;
    margin: 25px auto;
    padding: 15px 30px;
    background: #e94560;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover:not(:disabled) {
    background: #d63d57;
    transform: translateY(-1px);
}

.btn-primary:disabled {
    background: #444;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-secondary {
    padding: 10px 20px;
    background: #16213e;
    color: #eee;
    border: 2px solid #444;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    border-color: #e94560;
}

/* Tutorial Button */
.btn-tutorial {
    display: block;
    width: 100%;
    max-width: 400px;
    margin: 0 auto 25px;
    padding: 12px 20px;
    background: transparent;
    color: #9775fa;
    border: 2px solid #9775fa;
    border-radius: 12px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-tutorial:hover {
    background: rgba(151, 117, 250, 0.1);
}

/* Tutorial */
.tutorial {
    padding: 10px 0;
}

.btn-back {
    padding: 6px 14px;
    border: 1px solid #666;
    border-radius: 15px;
    background: transparent;
    color: #aaa;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 10px;
}

.btn-back:hover {
    border-color: #e94560;
    color: #eee;
}

.tutorial h2 {
    text-align: center;
    margin-bottom: 25px;
    color: #e94560;
}

.tutorial-section {
    background: #16213e;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
}

.tutorial-section h3 {
    margin-bottom: 12px;
    color: #eee;
}

.tutorial-content p {
    margin-bottom: 8px;
    line-height: 1.6;
    color: #ccc;
}

.tutorial-steps {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tutorial-step {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.step-number {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e94560;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1em;
    flex-shrink: 0;
}

.step-content h4 {
    margin-bottom: 4px;
    color: #eee;
}

.step-content p {
    color: #ccc;
    line-height: 1.5;
    font-size: 0.95em;
}

.tutorial-role-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-top: 10px;
}

.tutorial-role-card {
    display: flex;
    gap: 12px;
    padding: 10px;
    border-radius: 10px;
    align-items: center;
}

.tutorial-role-card img {
    width: 50px;
    height: 69px;
    object-fit: contain;
    border-radius: 6px;
    flex-shrink: 0;
}

.tutorial-role-info {
    flex: 1;
    min-width: 0;
}

.tutorial-role-name {
    font-weight: 600;
    font-size: 0.95em;
    margin-bottom: 2px;
}

.tutorial-role-team {
    font-size: 0.75em;
    color: #888;
    margin-bottom: 4px;
}

.tutorial-role-desc {
    font-size: 0.82em;
    color: #bbb;
    line-height: 1.4;
}

.role-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.role-table th {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 2px solid #444;
    color: #e94560;
}

.role-table td {
    padding: 7px 10px;
    border-bottom: 1px solid #2a2a4a;
    color: #ccc;
}

.role-table tr:hover td {
    background: rgba(233, 69, 96, 0.05);
}

/* Role Introduction */
.role-intro-list {
    margin: 20px 0;
}

.role-intro-item {
    background: #16213e;
    border-radius: 12px;
    padding: 15px 20px;
    margin-bottom: 12px;
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.role-intro-item .intro-icon {
    flex-shrink: 0;
}

.role-intro-item .intro-icon img {
    width: 55px;
    height: 76px;
    object-fit: contain;
    border-radius: 6px;
}

.hide-card-names .role-intro-item .intro-icon img {
    object-fit: cover;
    object-position: center bottom;
    height: 65px;
}

.role-intro-item .intro-content h3 {
    margin-bottom: 5px;
}

.role-intro-item .intro-content p {
    color: #aaa;
    font-size: 0.9em;
    line-height: 1.5;
}

/* Night Phase */
.night-scene {
    text-align: center;
    padding: 60px 20px;
    min-height: 70vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.moon {
    font-size: 4em;
    margin-bottom: 30px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.night-role-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
    min-height: 140px;
    justify-content: center;
}

.night-role-display img {
    width: 100px;
    height: 138px;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(233, 69, 96, 0.4);
    margin-bottom: 10px;
}

.hide-card-names .night-role-display img {
    object-fit: cover;
    object-position: center bottom;
    height: 120px;
}

.hide-card-names .disc-role-icon {
    object-fit: cover;
    object-position: center bottom;
}

.night-role-display .night-role-name {
    font-size: 1.3em;
    font-weight: 600;
    color: #e94560;
}

.night-status {
    font-size: 1.2em;
    margin-bottom: 20px;
    min-height: 2em;
    max-width: 400px;
    text-align: center;
    line-height: 1.5;
}

.night-timer {
    font-size: 3em;
    font-weight: bold;
    color: #e94560;
    margin: 20px 0;
    min-height: 1.2em;
}

.night-progress {
    width: 100%;
    max-width: 400px;
    height: 6px;
    background: #333;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 20px;
}

.progress-bar {
    height: 100%;
    background: #e94560;
    width: 0%;
    transition: width 1s linear;
}

/* Day / Discussion */
.day-scene {
    text-align: center;
    padding: 60px 20px;
}

.sun {
    font-size: 4em;
    margin-bottom: 20px;
}

.discussion-timer {
    font-size: 4em;
    font-weight: bold;
    color: #ffd43b;
    margin: 30px 0;
}

.discussion-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 30px;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.loading-overlay .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #333;
    border-top-color: #e94560;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    margin-top: 15px;
    font-size: 1.1em;
}

/* Discussion Role Reference */
.discussion-roles {
    margin: 30px 0;
    text-align: left;
}

.discussion-roles h3 {
    text-align: center;
    margin-bottom: 15px;
    color: #aaa;
    font-size: 0.95em;
}

.discussion-role-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.discussion-role-item {
    background: #16213e;
    border-radius: 10px;
    padding: 12px 15px;
}

.disc-role-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

.disc-role-icon {
    width: 40px;
    height: 55px;
    object-fit: contain;
    border-radius: 5px;
}

.disc-role-name {
    font-weight: 600;
    font-size: 0.95em;
}

.disc-role-order {
    margin-left: auto;
    font-size: 0.8em;
    color: #888;
    background: #0f1a30;
    padding: 3px 8px;
    border-radius: 10px;
}

.disc-role-desc {
    font-size: 0.85em;
    color: #aaa;
    line-height: 1.4;
    padding-left: 33px;
}

.audio-controls {
    position: fixed;
    bottom: 15px;
    right: 15px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,0.6);
    padding: 6px 12px;
    border-radius: 22px;
}

.mute-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #eee;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mute-btn:hover {
    color: #e94560;
}

#volume-slider {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #444;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #e94560;
    cursor: pointer;
}
