@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
    --bg-1: #0a0608;
    --bg-2: #17090a;
    --ember: #ff7a1a;
    --ember-2: #ff9a3c;
    --ember-soft: rgba(255, 122, 26, 0.35);
    --gold: #ffd79a;
    --card: rgba(24, 15, 18, 0.92);
    --card-2: rgba(34, 18, 16, 0.92);
    --text: #f3e7dc;
    --muted: #c2a894;
    --line: rgba(255, 122, 26, 0.28);
    --good: #7cfc98;
}

* {
    box-sizing: border-box;
}

html, body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    color: var(--text);
    background:
        radial-gradient(1200px 720px at 12% -12%, rgba(255, 122, 26, 0.16), transparent 60%),
        radial-gradient(900px 520px at 92% 6%, rgba(255, 60, 10, 0.14), transparent 62%),
        linear-gradient(160deg, var(--bg-1), var(--bg-2));
    background-attachment: fixed;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

/* Slow ember glow behind everything */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 18% 82%, rgba(255, 122, 26, 0.12) 0%, transparent 46%),
        radial-gradient(circle at 84% 14%, rgba(255, 60, 10, 0.12) 0%, transparent 42%);
    animation: emberDrift 16s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes emberDrift {
    0%, 100% { transform: translateY(0) scale(1); opacity: 0.9; }
    50% { transform: translateY(-18px) scale(1.05); opacity: 1; }
}

/* ---------- Site chrome ---------- */
.site-header,
.site-footer {
    max-width: 1100px;
    margin: 0 auto;
    padding: 18px 20px;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
}

.brand {
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--ember-2);
    text-decoration: none;
    text-shadow: 0 0 18px var(--ember-soft);
}

.site-nav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.site-nav a {
    color: var(--muted);
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: 600;
    transition: all 0.25s ease;
}

.site-nav a.active,
.site-nav a:hover {
    color: var(--text);
    border-color: var(--line);
    background: rgba(255, 122, 26, 0.14);
}

.site-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 22px 20px 28px;
}

.route-section {
    display: none;
    animation: fadeIn 0.25s ease;
}

.route-section.active {
    display: block;
}

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

/* ---------- Hero ---------- */
.title {
    text-align: center;
    font-family: 'Cinzel', serif;
    font-size: clamp(2.6rem, 9vw, 4.4rem);
    font-weight: 700;
    color: transparent;
    background: linear-gradient(45deg, #ff4500, #ffb020, #ff6347, #ff4500);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    background-clip: text;
    animation: fireGlow 4s ease-in-out infinite;
    text-shadow: 0 0 40px rgba(255, 69, 0, 0.35);
    margin: 18px 0 6px;
    letter-spacing: 3px;
}

@keyframes fireGlow {
    0%, 100% { background-position: 0% 50%; filter: brightness(1); }
    50% { background-position: 100% 50%; filter: brightness(1.18); }
}

.hero-copy {
    max-width: 640px;
    margin: 14px auto 18px;
    text-align: center;
    color: var(--muted);
    font-size: 1.02rem;
    line-height: 1.5;
}

/* ---------- Menu card ---------- */
#menu {
    margin: 0 auto;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--card);
    backdrop-filter: blur(10px);
    width: min(560px, 100%);
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.5), 0 0 60px rgba(255, 122, 26, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.menu-header {
    background: linear-gradient(90deg, #b8410a, #ff7a1a);
    padding: 18px 20px;
    text-align: center;
    position: relative;
}

.menu-header::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
}

.menu-title {
    font-family: 'Cinzel', serif;
    font-size: 1.7rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    letter-spacing: 1px;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.menu-content {
    padding: 28px;
}

.player-name-section {
    margin-bottom: 26px;
}

.player-name-section label,
.form-group label {
    display: block;
    color: var(--ember-2);
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tabs {
    display: flex;
    margin-bottom: 24px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.35);
    padding: 4px;
}

.tab {
    flex: 1;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: rgba(243, 231, 220, 0.7);
    cursor: pointer;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.92rem;
    transition: all 0.25s ease;
}

.tab:hover {
    color: var(--ember-2);
    background: rgba(255, 122, 26, 0.1);
}

.tab.active {
    background: linear-gradient(135deg, #b8410a, #ff7a1a);
    color: #fff;
    box-shadow: 0 4px 14px rgba(255, 69, 0, 0.35);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

input, select {
    width: 100%;
    padding: 13px 16px;
    border: 2px solid var(--line);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 1rem;
    transition: all 0.25s ease;
    font-family: 'Inter', sans-serif;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--ember-2);
    box-shadow: 0 0 0 3px rgba(255, 122, 26, 0.2);
    background: rgba(0, 0, 0, 0.6);
}

input::placeholder {
    color: rgba(243, 231, 220, 0.45);
}

button {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #c8460b, #ff8a24);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    letter-spacing: 0.4px;
    position: relative;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
}

button::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
    transition: left 0.5s ease;
}

button:hover::before { left: 100%; }

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(255, 90, 10, 0.4);
}

button:active { transform: translateY(0); }

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.form-group { margin-bottom: 20px; }

.form-row {
    display: flex;
    gap: 15px;
    align-items: end;
}

.form-row select { flex: 1; }

.section-heading {
    color: var(--gold);
    text-align: center;
    margin-bottom: 12px;
    font-family: 'Cinzel', serif;
}

.section-sub {
    color: rgba(243, 231, 220, 0.8);
    text-align: center;
    margin-bottom: 20px;
    font-size: 0.92rem;
}

#status {
    background: rgba(255, 122, 26, 0.1);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
    margin-top: 20px;
    color: var(--ember-2);
    text-align: center;
    font-weight: 600;
    position: relative;
    overflow: hidden;
}

#status::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 165, 0, 0.2), transparent);
    animation: loadingShimmer 2s infinite;
}

@keyframes loadingShimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.loading-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 165, 0, 0.3);
    border-radius: 50%;
    border-top-color: var(--ember-2);
    animation: spin 1s ease-in-out infinite;
    margin-right: 10px;
    vertical-align: middle;
}

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

#lobbyInfo {
    background: rgba(124, 252, 152, 0.08);
    border: 1px solid rgba(124, 252, 152, 0.3);
    border-radius: 10px;
    padding: 15px;
    margin-top: 20px;
    color: #bff6c9;
    font-size: 0.92rem;
}

.share-block {
    display: grid;
    gap: 8px;
}

.share-link {
    color: var(--gold);
    word-break: break-all;
    text-decoration: none;
}

.share-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.share-actions button {
    width: auto;
    padding: 8px 14px;
    font-size: 0.9rem;
}

/* ---------- Feedback buttons ---------- */
.menu-feedback-section {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.menu-feedback-btn {
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    padding: 10px 16px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.25s ease;
    border: 1px solid var(--line);
    font-size: 0.9rem;
}

.menu-feedback-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}

.menu-feedback-btn.discord {
    background: linear-gradient(135deg, #5865F2, #7289DA);
    border-color: transparent;
}

/* ---------- Guide + Contact ---------- */
.guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 14px;
}

.guide-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--card);
    padding: 16px;
    color: var(--text);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.guide-card:hover {
    transform: translateY(-3px);
    border-color: var(--ember-2);
}

.guide-card h3 {
    margin: 0 0 8px;
    font-family: 'Cinzel', serif;
    color: var(--ember-2);
    font-size: 1.05rem;
}

.contact-panel {
    max-width: 720px;
    margin: 0 auto;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--card);
    padding: 20px;
}

.contact-panel textarea {
    width: 100%;
    min-height: 150px;
    padding: 12px 14px;
    border: 2px solid var(--line);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font: inherit;
    resize: vertical;
}

/* ---------- Footer ---------- */
.site-footer {
    border-top: 1px solid var(--line);
    color: var(--muted);
    text-align: center;
    padding-bottom: 26px;
}

.site-footer a {
    color: var(--gold);
    text-decoration: none;
    border-bottom: 1px solid var(--line);
    transition: color 0.2s ease, border-color 0.2s ease;
}

.site-footer a:hover {
    color: #fff;
    border-bottom-color: var(--ember-2);
}

/* ---------- Game canvas ---------- */
canvas {
    display: block;
    margin: 18px auto;
    border-radius: 14px;
    touch-action: none;
    box-shadow: 0 0 50px rgba(255, 69, 0, 0.28), 0 0 110px rgba(255, 140, 0, 0.15), inset 0 0 0 2px rgba(255, 255, 255, 0.06);
}

/* Immersive in-game mode: hide chrome, go edge-to-edge */
body.in-game {
    overflow: hidden;
    height: 100dvh;
}

body.in-game .site-header,
body.in-game .site-footer,
body.in-game .site-main {
    display: none;
}

body.in-game canvas {
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    touch-action: none;
}

/* Controls hint toast */
.mobile-controls-hint {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 8, 12, 0.88);
    border: 1px solid var(--line);
    color: #fff;
    padding: 12px 20px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 1000;
    text-align: center;
    max-width: 88vw;
    animation: fadeInOut 5s ease-in-out;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    12%, 82% { opacity: 1; }
}

/* Rotate-to-landscape prompt (only during play, narrow portrait) */
.rotate-notice {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1500;
    background: linear-gradient(160deg, var(--bg-1), var(--bg-2));
    color: var(--text);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
    gap: 14px;
}

.rotate-notice .rotate-icon {
    font-size: 3rem;
    animation: rotateHint 2s ease-in-out infinite;
}

.rotate-notice h2 {
    font-family: 'Cinzel', serif;
    color: var(--ember-2);
    margin: 0;
}

@keyframes rotateHint {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}

@media (max-width: 820px) and (orientation: portrait) {
    body.in-game .rotate-notice {
        display: flex;
    }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .site-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .menu-content { padding: 20px; }

    .tabs { flex-direction: column; }

    .tab { margin-bottom: 2px; }

    .form-row { flex-direction: column; }

    #menu { width: 100%; }

    .menu-feedback-section { flex-direction: column; }
}

/* Hidden states */
#menu.hidden,
.title.hidden,
.instructions.hidden {
    display: none;
}
