/* Ninja Slash — Feudal Dojo Style */

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

:root {
    --bg-deep:     #0a0606;
    --bg-mid:      #1a0d0d;
    --bg-soft:     #2a1410;
    --gold:        #d4af37;
    --gold-soft:   #f0d272;
    --red:         #c8102e;
    --red-soft:    #ff5a6c;
    --cream:       #f5e6c8;
    --bamboo:      rgba(139, 110, 68, 0.25);
    --text-white:  #f5e6c8;
    --text-muted:  #8a6a3d;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(ellipse at 50% 0%, #3a1313 0%, var(--bg-mid) 45%, var(--bg-deep) 100%);
    min-height: calc(100dvh - 3.5rem);
    color: var(--text-white);
}

/* ============ BAMBOO BACKGROUND ============ */
#bamboo-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.bamboo {
    position: absolute;
    top: -5%;
    width: 0.5rem;
    height: 110%;
    background: linear-gradient(180deg,
        rgba(139, 110, 68, 0) 0%,
        var(--bamboo) 15%,
        var(--bamboo) 85%,
        rgba(139, 110, 68, 0) 100%);
    border-left: 1px solid rgba(212, 175, 55, 0.08);
    border-right: 1px solid rgba(0, 0, 0, 0.35);
    transform-origin: 50% 0%;
    animation: bambooSway 6s ease-in-out infinite alternate;
}

.bamboo.b1 { left: 6%;  animation-delay: 0s;   }
.bamboo.b2 { left: 24%; animation-delay: 1.5s; }
.bamboo.b3 { left: 52%; animation-delay: 0.7s; }
.bamboo.b4 { left: 74%; animation-delay: 2.2s; }
.bamboo.b5 { left: 92%; animation-delay: 1.1s; }

@keyframes bambooSway {
    0%   { transform: rotate(-0.6deg); }
    100% { transform: rotate( 0.6deg); }
}

/* ============ SCREENS ============ */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--bg-deep);
    color: var(--text-white);
    z-index: 1000;
}

.screen.hidden { display: none; }

/* ============ GAME CONTAINER ============ */
#game-container {
    width: 100%;
    max-width: 31.25rem;       /* ~500px */
    height: 100%;
    max-height: 56rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0.75rem;
    position: relative;
    z-index: 1;
}

#game-container.hidden { display: none; }

/* ============ HEADER ============ */
#game-header {
    width: 100%;
    padding: 0.375rem 0;
    display: flex;
    justify-content: center;
}

.balance-display {
    background: linear-gradient(180deg, rgba(212, 175, 55, 0.12) 0%, rgba(200, 16, 46, 0.06) 100%);
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 1.25rem;
    padding: 0.4375rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.4375rem;
    box-shadow: 0 0 1.125rem rgba(212, 175, 55, 0.15);
}

.balance-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

#balance-value {
    color: var(--gold);
    font-size: 1.25rem;
    font-weight: 700;
    min-width: 4.375rem;
    text-align: right;
    text-shadow: 0 0 0.625rem rgba(212, 175, 55, 0.5);
    transition: color 0.3s ease;
}

.balance-currency { color: var(--red-soft); font-size: 0.6875rem; }

/* ============ HUD ============ */
#hud {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4375rem 0.75rem;
    background: linear-gradient(180deg, #1a0606 0%, #240a0a 100%);
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 0.625rem;
    margin: 0.25rem 0;
    box-shadow: inset 0 0.0625rem 0 rgba(255, 255, 255, 0.04);
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.hud-label {
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

#score-value {
    color: var(--gold);
    font-size: 1.1rem;
    font-weight: 800;
    min-width: 2.5rem;
    text-shadow: 0 0 0.625rem rgba(212, 175, 55, 0.5);
}

#time-value {
    color: var(--cream);
    font-size: 1.1rem;
    font-weight: 800;
    min-width: 2rem;
    text-align: right;
    transition: color 0.2s ease;
}

#time-value.urgent {
    color: var(--red-soft);
    animation: urgentPulse 0.5s ease-in-out infinite;
}

@keyframes urgentPulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.15); }
}

.hud-item.lives {
    gap: 0.25rem;
    transition: transform 0.15s ease;
}

.hud-item.lives.pulse {
    animation: livesShake 0.4s ease;
}

@keyframes livesShake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-0.3rem); }
    75%      { transform: translateX(0.3rem); }
}

.heart {
    color: var(--red-soft);
    font-size: 1.05rem;
    filter: drop-shadow(0 0 0.375rem rgba(255, 90, 108, 0.6));
    transition: all 0.4s ease;
}

.heart.lost {
    color: rgba(80, 30, 30, 0.55);
    filter: none;
    transform: scale(0.85);
}

/* ============ GAME ARENA ============ */
#game-arena {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: stretch;
    width: 100%;
    padding: 0.25rem 0;
    min-height: 18rem;
}

.arena-frame {
    position: relative;
    width: 100%;
    border-radius: 1rem;
    overflow: hidden;
    background:
        linear-gradient(180deg, #1a0606 0%, #0a0303 100%) padding-box,
        linear-gradient(135deg, var(--gold) 0%, var(--red) 50%, var(--gold) 100%) border-box;
    border: 0.1875rem solid transparent;
    box-shadow:
        0 0 0 0.0625rem rgba(0, 0, 0, 0.8),
        0 0 2.5rem rgba(200, 16, 46, 0.25),
        0 1rem 2.5rem rgba(0, 0, 0, 0.6),
        inset 0 0.0625rem 0 rgba(255, 255, 255, 0.05);
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

/* ============ OVERLAYS ============ */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    pointer-events: none;
    background: rgba(10, 6, 6, 0.55);
    backdrop-filter: blur(2px);
    z-index: 10;
}

.overlay.hidden { display: none; }

.kanji-banner {
    font-size: 5rem;
    color: var(--red);
    text-shadow:
        0 0 1.25rem rgba(200, 16, 46, 0.7),
        0 0 0.25rem #000;
    background: var(--cream);
    width: 6rem;
    height: 6rem;
    line-height: 6rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    border: 0.1875rem solid var(--bg-deep);
    box-shadow: 0 0 1.5rem rgba(212, 175, 55, 0.45);
}

.overlay-title {
    color: var(--gold);
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 0.25rem;
    text-shadow: 0 0 1rem rgba(212, 175, 55, 0.6);
    text-transform: uppercase;
}

.overlay-hint {
    margin-top: 0.5rem;
    color: var(--cream);
    font-size: 0.875rem;
    opacity: 0.85;
}

/* ============ RESULT DISPLAY ============ */
#result-display {
    background: linear-gradient(160deg, rgba(20, 6, 6, 0.97) 0%, rgba(40, 10, 10, 0.97) 100%);
    backdrop-filter: blur(4px);
    animation: resultPopup 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes resultPopup {
    0%   { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1);   opacity: 1; }
}

.result-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 0 0.75rem rgba(212, 175, 55, 0.6));
}

.result-title {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.125rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.result-title.win  { color: var(--gold); text-shadow: 0 0 1.125rem rgba(212, 175, 55, 0.6); }
.result-title.lose { color: var(--red-soft); }

.result-score {
    font-size: 0.95rem;
    color: var(--cream);
    margin-bottom: 0.5rem;
    opacity: 0.85;
}

.result-multiplier {
    font-size: 2rem;
    font-weight: 800;
    color: var(--gold-soft);
    text-shadow: 0 0 1.125rem rgba(212, 175, 55, 0.6);
    margin-bottom: 0.25rem;
}

.result-multiplier.hidden,
.result-amount.hidden { display: none; }

.result-amount {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--cream);
}

/* ============ BET CONTROLS ============ */
#bet-controls {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0.25rem;
    flex-wrap: wrap;
}

.bet-label {
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.bet-buttons { display: flex; gap: 0.375rem; }

.bet-btn {
    width: 3rem;
    height: 2rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 0.375rem;
    color: rgba(245, 230, 200, 0.65);
    font-size: 0.8125rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.bet-btn:hover:not(:disabled) {
    border-color: var(--gold);
    color: var(--text-white);
    background: rgba(212, 175, 55, 0.08);
}

.bet-btn.active {
    background: linear-gradient(160deg, var(--gold) 0%, #a07a1f 100%);
    color: var(--bg-deep);
    border-color: var(--gold-soft);
    box-shadow: 0 0.125rem 0.75rem rgba(212, 175, 55, 0.4);
}

.bet-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.current-bet {
    background: rgba(0, 0, 0, 0.35);
    padding: 0.25rem 0.875rem;
    border-radius: 0.375rem;
    border: 1px solid rgba(212, 175, 55, 0.2);
}

#current-bet-value {
    color: var(--gold);
    font-size: 1rem;
    font-weight: 700;
}

/* ============ ACTION BUTTON ============ */
#action-button {
    width: 11.25rem;
    height: 3.25rem;
    background: linear-gradient(160deg, var(--gold) 0%, #b8860b 55%, var(--red) 100%);
    border: 1px solid rgba(240, 210, 114, 0.5);
    border-radius: 1.625rem;
    cursor: pointer;
    box-shadow:
        0 0.25rem 1.375rem rgba(212, 175, 55, 0.45),
        0 0.0625rem 0 rgba(255, 255, 255, 0.2) inset;
    transition: all 0.18s ease;
    margin: 0.5rem 0;
    color: var(--bg-deep);
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.1875rem;
}

#action-button:hover:not(:disabled) {
    transform: translateY(-0.125rem);
    box-shadow: 0 0.5rem 1.875rem rgba(200, 16, 46, 0.55);
}

#action-button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 0.125rem 0.625rem rgba(212, 175, 55, 0.3);
}

#action-button:disabled {
    background: linear-gradient(160deg, #2a1818 0%, #1a0e0e 100%);
    border-color: rgba(255, 255, 255, 0.08);
    color: #6a4f4f;
    box-shadow: none;
    cursor: not-allowed;
}

#action-button.playing {
    background: linear-gradient(160deg, #4a2424 0%, #2a1010 100%);
    color: var(--gold-soft);
    border-color: rgba(212, 175, 55, 0.25);
}

#action-text { display: inline-block; }

/* ============ GAME TITLE ============ */
.game-title {
    display: flex;
    align-items: baseline;
    gap: 0.375rem;
    padding: 0.25rem 0 0.5rem;
}

.title-main {
    color: rgba(245, 230, 200, 0.35);
    font-size: 0.6875rem;
    letter-spacing: 0.125rem;
    text-transform: uppercase;
}

.title-accent {
    color: var(--red-soft);
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.125rem;
    text-shadow: 0 0 0.875rem rgba(255, 90, 108, 0.55);
    text-transform: uppercase;
}

/* ============ MESSAGE DISPLAY ============ */
#message-display {
    position: fixed;
    bottom: 6rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 6, 6, 0.94);
    padding: 0.5rem 1.375rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(212, 175, 55, 0.35);
    z-index: 100;
    white-space: nowrap;
    box-shadow: 0 0 1.25rem rgba(0, 0, 0, 0.5);
}

#message-display.hidden { display: none; }

#message-text {
    color: var(--cream);
    font-size: 0.8125rem;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 25rem) {
    .bet-btn { width: 2.625rem; height: 1.875rem; font-size: 0.75rem; }
    #action-button { width: 9.5rem; height: 2.875rem; font-size: 1.0625rem; }
    .kanji-banner { font-size: 3.75rem; width: 4.5rem; height: 4.5rem; line-height: 4.5rem; }
    .overlay-title { font-size: 1.25rem; }
}

@media (max-height: 43.75rem) {
    #game-arena { padding: 0; }
    .balance-display { padding: 0.3rem 1rem; }
    #balance-value { font-size: 1.05rem; }
    #action-button { height: 2.75rem; margin: 0.25rem 0; }
}
