/* Reset & Base Settings */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-dark: #0a0a14;
    --accent-gold: #d4af37;
    --accent-red: #c1272d;
    --text-light: #e0e0e0;
    --glass-bg: rgba(20, 20, 35, 0.65);
    --glass-border: rgba(255, 255, 255, 0.1);
    --tile-bg: #2a2a35;
    --tile-broken: #111116;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-light);
    overflow: hidden; /* Hide scrollbars, full screen app */
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Background Effects */
.bg-moon {
    position: absolute;
    top: 5%;
    right: 10%;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, #fffdf0 10%, #d4af37 60%, transparent 80%);
    border-radius: 50%;
    box-shadow: 0 0 50px 10px rgba(212, 175, 55, 0.3);
    z-index: -3;
    animation: pulseMoon 10s infinite alternate;
}

@keyframes pulseMoon {
    0% { transform: scale(1); box-shadow: 0 0 50px 10px rgba(212, 175, 55, 0.3); }
    100% { transform: scale(1.05); box-shadow: 0 0 70px 15px rgba(212, 175, 55, 0.5); }
}

.bg-clouds {
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 100%;
    background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 200 100" xmlns="http://www.w3.org/2000/svg"><path fill="rgba(255,255,255,0.02)" d="M50 50 Q 70 30 90 50 T 130 50 T 170 50 Z"/></svg>') repeat;
    background-size: 400px 200px;
    z-index: -2;
    animation: moveClouds 60s linear infinite;
}

@keyframes moveClouds {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

#particles-js {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

/* Common UI */
#app {
    width: 100%;
    max-width: 1200px;
    height: 100%;
    position: relative;
    padding: 20px;
}

.screen {
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.5s ease;
}

.screen.active {
    display: flex;
}

.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Typography */
h1, h2, h3 {
    font-family: 'Yuji Syuku', serif;
    letter-spacing: 2px;
}

/* Glass Panel */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Buttons */
button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-red), #901a1e);
    color: white;
    box-shadow: 0 4px 15px rgba(193, 39, 45, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(193, 39, 45, 0.6);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-secondary {
    background: transparent;
    color: var(--accent-gold);
    border: 1px solid var(--accent-gold);
}

.btn-secondary:hover {
    background: rgba(212, 175, 55, 0.1);
}

/* Title Screen */
.title-container {
    text-align: center;
}

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

@keyframes zoomFadeIn {
    0% {
        opacity: 0;
        transform: scale(2);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.main-title {
    font-size: 4rem;
    margin-bottom: 10px;
    text-shadow: 0 0 20px rgba(0,0,0,0.8);
}

.title-ninja {
    color: white;
}

.title-drop {
    color: var(--accent-red);
}

.subtitle {
    font-size: 1.5rem;
    color: var(--accent-gold);
    margin-bottom: 40px;
    font-family: 'Yuji Syuku', serif;
}

.join-form {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.join-form input {
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(0,0,0,0.5);
    color: white;
    font-size: 1.1rem;
    width: 250px;
}

/* Lobby Screen */
.lobby-panel {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.lobby-panel h2 {
    text-align: center;
    color: var(--accent-gold);
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 15px;
}

.settings-section, .players-section {
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 10px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.setting-row input, .setting-row select {
    width: 80px;
    padding: 5px;
    border-radius: 5px;
    border: 1px solid var(--glass-border);
    background: #1a1a24;
    color: white;
    text-align: center;
}

.setting-row input:disabled, .setting-row select:disabled {
    background: rgba(0, 0, 0, 0.5);
    color: #666;
    border-color: #333;
    cursor: not-allowed;
    opacity: 0.6;
}

.player-list {
    list-style: none;
    margin-top: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.player-list li {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex;
    justify-content: space-between;
}

.action-section {
    text-align: center;
}

/* Game Screen */
#screen-game {
    justify-content: flex-start;
    padding-top: 20px;
}

.game-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.round-info {
    font-size: 1.5rem;
    font-family: 'Yuji Syuku', serif;
    color: var(--accent-gold);
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.status-bar {
    font-size: 1.2rem;
    font-weight: bold;
    color: white;
    background: rgba(0,0,0,0.5);
    padding: 8px 20px;
    border-radius: 20px;
    border: 1px solid var(--accent-gold);
}

/* Board */
.board-container {
    position: relative;
    width: 100%;
    height: 120px;
    margin-bottom: 40px;
}

.tiles-wrapper {
    display: flex;
    width: 100%;
    height: 100%;
    gap: 5px;
    justify-content: center;
    align-items: center;
}

.tile {
    width: 7%;
    height: 80px;
    background: linear-gradient(to bottom, #3a3a45, #1a1a25);
    border: 1px solid #4a4a55;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    font-weight: bold;
    color: rgba(255,255,255,0.5);
    position: relative;
    box-shadow: inset 0 2px 5px rgba(255,255,255,0.1), 0 5px 10px rgba(0,0,0,0.5);
    transition: all 0.5s ease;
}

.tile.start-tile {
    background: linear-gradient(to bottom, #4a4a35, #2a2a15);
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.tile.broken {
    background: var(--tile-broken);
    border-color: #050505;
    box-shadow: inset 0 10px 20px rgba(0,0,0,0.8);
    transform: translateY(20px) rotate(5deg);
    opacity: 0.3;
    color: transparent;
}

.tile.highlight-target {
    box-shadow: 0 0 20px 5px rgba(85, 239, 196, 0.8), inset 0 2px 5px rgba(255,255,255,0.3);
    border-color: #55efc4;
    transform: translateY(-5px);
    z-index: 5;
}

.tile.highlight-danger {
    box-shadow: 0 0 20px 5px rgba(255, 118, 117, 0.8), inset 0 2px 5px rgba(255,255,255,0.3);
    border-color: #ff7675;
    transform: translateY(-5px) rotate(5deg);
    opacity: 1;
    z-index: 5;
}

/* Players on Board */
#board-players {
    position: absolute;
    top: -30px;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let clicks pass through */
}

.player-avatar {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: left 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94), top 0.5s ease;
    transform: translateX(-50%);
    z-index: 10;
}

.player-img-container {
    position: relative;
    width: 65px;
    height: 65px;
    display: inline-block;
    isolation: isolate;
}

.player-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: absolute;
    top: 0;
    left: 0;
}

.player-img-tint {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    mix-blend-mode: multiply;
    mask-image: url('../img/ninja_mask.png');
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
    -webkit-mask-image: url('../img/ninja_mask.png');
    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
}

.player-name-tag {
    font-size: 0.75rem;
    font-weight: bold;
    color: white;
    background: rgba(0,0,0,0.7);
    padding: 2px 6px;
    border-radius: 4px;
    margin-bottom: 2px;
    white-space: nowrap;
    z-index: 11;
}

.player-avatar.dead {
    opacity: 0;
    top: 100px !important;
    transition: all 1s ease-in;
}

/* Game UI Grid */
.game-ui {
    display: grid;
    grid-template-columns: 250px 1fr 300px;
    gap: 20px;
    width: 100%;
    flex: 1;
    min-height: 0;
}

/* Player Stats */
.player-stats {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.player-stats ul {
    list-style: none;
    margin-top: 15px;
    flex: 1;
    overflow-y: auto;
}

.player-stats li {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-stats .dead {
    opacity: 0.5;
    text-decoration: line-through;
}

/* Controls */
.controls-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 0;
    overflow-y: auto;
}

.dice-container {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
}

.die {
    width: 60px;
    height: 60px;
    background: white;
    color: black;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: bold;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5), 0 5px 15px rgba(0,0,0,0.3);
}

.die.rolling {
    animation: shake 0.5s infinite;
}

@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.action-area {
    text-align: center;
    width: 100%;
}

.btn-action {
    font-size: 1.2rem;
    padding: 15px 30px;
}

.move-options p {
    margin-bottom: 15px;
    color: var(--accent-gold);
}

.buttons-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.btn-move {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
}

.btn-move:hover {
    background: rgba(255,255,255,0.2);
}

/* Log Panel */
.log-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.logs-container {
    margin-top: 15px;
    flex: 1;
    overflow-y: auto;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.log-entry {
    background: rgba(0,0,0,0.4);
    padding: 8px 10px;
    border-radius: 5px;
    border-left: 3px solid #555;
}

.log-entry.important {
    border-left-color: var(--accent-red);
    color: #ffbaba;
}

.log-entry.success {
    border-left-color: var(--accent-gold);
    color: #fff0b3;
}

/* Scrollbar for logs */
.logs-container::-webkit-scrollbar {
    width: 6px;
}

.logs-container::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}

.logs-container::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}
