/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: #121212;
    color: #e8e8e8;
    min-height: 100vh;
}
a { color: #60a5fa; text-decoration: none; }
h1:focus { outline: none; }
button { font: inherit; }

/* ---------- Layout ---------- */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 1rem;
}

.panel {
    background: #1e1e1e;
    border-radius: 1rem;
    width: 100%;
    max-width: 42rem;
    min-height: 12rem;
    padding: 1.25rem;
    box-shadow: 0 4px 32px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

@media (min-width: 640px) {
    .main { padding: 2rem; }
    .panel { min-height: 480px; padding: 2.5rem; }
}

/* ---------- Nav ---------- */
.nav {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    padding: 0 1rem;
    min-height: 3.5rem;
    gap: 0.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
    background: linear-gradient(to right, rgb(5, 39, 103), #3a0647);
}

.nav-brand {
    color: white;
    font-weight: bold;
    font-size: 1.125rem;
    padding: 0.5rem 0;
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.nav-item {
    color: #d1d5db;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    transition: background-color 0.15s, color 0.15s;
}

.nav-item:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.nav-item.active {
    color: white;
    background: rgba(255, 255, 255, 0.25);
}

@media (min-width: 640px) {
    .nav { padding: 0 1.5rem; gap: 2rem; }
}

/* ---------- Buttons ---------- */
.btn {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    color: white;
    border: 0;
    cursor: pointer;
    transition: filter 0.15s, transform 0.05s, background-image 0.15s;
}

.btn:active {
    transform: scale(0.9);
    filter: brightness(0.75);
}

.btn-blue { background: linear-gradient(to right, #3b82f6, #1d4ed8); }
.btn-blue:hover { background: linear-gradient(to right, #60a5fa, #2563eb); }

.btn-purple { background: linear-gradient(to right, #a855f7, #7e22ce); }
.btn-purple:hover { background: linear-gradient(to right, #c084fc, #9333ea); }

.btn-row {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Tabs (dice selector) */
.tab-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    padding: 0.25rem;
    max-width: 20rem;
}

.tab {
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: transparent;
    color: #9ca3af;
    border: 0;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.tab:hover { color: white; background: rgba(255, 255, 255, 0.1); }
.tab.active { background: rgba(255, 255, 255, 0.25); color: white; }
.tab:active { transform: scale(0.9); filter: brightness(0.75); }

/* Inputs */
.num-input {
    width: 6rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    background: #1f2937;
    color: white;
    border: 1px solid #4b5563;
    text-align: center;
    font: inherit;
}

/* ---------- Page: Home ---------- */
.welcome {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}
.welcome-text {
    font-size: 1.5rem;
    margin: 0;
}

/* ---------- Page: Number ---------- */
.number-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
}
.big-number {
    font-size: 6rem;
    font-weight: bold;
    margin: 0;
}
.input-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.input-label {
    font-size: 0.875rem;
    color: #9ca3af;
}
.error-text {
    color: #f87171;
    font-size: 0.875rem;
    margin: 0;
}

/* ---------- Page: Cards ---------- */
.cards-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    margin-top: 2.5rem;
}
.playing-card {
    width: 11rem;
    aspect-ratio: 5 / 7;
    border-radius: 0.75rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}
.card-preload {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
}
.card-preload img { width: 1px; height: 1px; }

/* ---------- Page: Coin / Dice / Color ---------- */
.shape-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    margin-top: 1.5rem;
}
.shape-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 160px;
}
.dice-row {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    align-items: center;
    min-height: 130px;
}
.color-circle {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* ---------- Page: Stars ---------- */
.stars-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 16rem;
    color: #9ca3af;
}
.stars-canvas {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: black;
    height: calc(75vh - 75px);
}
.star {
    position: absolute;
    cursor: pointer;
}
.star-inner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
}
.star-inner:hover { transform: scale(1.5); }
.star-glyph {
    color: #fef3c7;
    text-shadow: 0 0 6px #fef9c3, 0 0 14px #fbbf24;
}
.star-label {
    position: absolute;
    white-space: nowrap;
    color: white;
    font-weight: bold;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 0.25rem;
    padding: 0 0.25rem;
    top: -1.6em;
    font-size: 11px;
}

@keyframes float1 { 0% { transform: translate(0, 0); } 100% { transform: translate(8px, -10px); } }
@keyframes float2 { 0% { transform: translate(0, 0); } 100% { transform: translate(-7px, 9px); } }
@keyframes float3 { 0% { transform: translate(0, 0); } 100% { transform: translate(10px, 6px); } }
@keyframes float4 { 0% { transform: translate(0, 0); } 100% { transform: translate(-9px, -7px); } }
@keyframes float5 { 0% { transform: translate(0, 0); } 100% { transform: translate(6px, -12px); } }
@keyframes float6 { 0% { transform: translate(0, 0); } 100% { transform: translate(-11px, 8px); } }
@keyframes float7 { 0% { transform: translate(0, 0); } 100% { transform: translate(7px, 11px); } }
@keyframes float8 { 0% { transform: translate(0, 0); } 100% { transform: translate(-6px, -9px); } }

/* ---------- Page: History ---------- */
.history-page {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0.25rem;
}
.history-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #d1d5db;
    margin: 0;
}
.history-count {
    font-size: 0.875rem;
    font-weight: normal;
    color: #6b7280;
}
.btn-link-danger {
    font-size: 0.875rem;
    padding: 0.25rem 0.75rem;
    color: #f87171;
    background: transparent;
    border: 0;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, transform 0.05s, filter 0.15s;
}
.btn-link-danger:hover { color: #fca5a5; background: rgba(248, 113, 113, 0.1); }
.btn-link-danger:active { transform: scale(0.9); filter: brightness(0.75); }

.history-empty {
    color: #9ca3af;
    text-align: center;
    margin-top: 2rem;
}
.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.history-entry {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    transition: background-color 0.15s;
}
.history-entry:hover { background: rgba(255, 255, 255, 0.08); }

.history-time {
    font-size: 0.75rem;
    color: #6b7280;
    width: 5rem;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.badge {
    font-size: 0.75rem;
    font-weight: 600;
    width: 3.5rem;
    text-align: center;
    flex-shrink: 0;
    border-radius: 9999px;
    padding: 0.125rem 0.25rem;
}
.badge-number { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
.badge-card { background: rgba(34, 197, 94, 0.2); color: #86efac; }
.badge-dice { background: rgba(168, 85, 247, 0.2); color: #d8b4fe; }
.badge-coin { background: rgba(156, 163, 175, 0.2); color: #d1d5db; }
.badge-stars { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.badge-color { background: rgba(236, 72, 153, 0.2); color: #f9a8d4; }
.badge-default { background: rgba(107, 114, 128, 0.2); color: #d1d5db; }

.history-value {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}
.value-number { font-size: 1.5rem; font-weight: bold; color: white; }
.value-card-img { height: 3rem; border-radius: 0.25rem; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }
.value-dice { font-size: 0.875rem; color: #9ca3af; }
.value-dice-num { font-weight: bold; color: white; font-size: 1rem; }
.value-dice-sep { color: #6b7280; }
.value-coin { font-weight: 600; color: white; }
.value-star { color: #fde047; font-size: 1.125rem; }
.value-color-swatch {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}
.value-color-text { font-size: 0.875rem; color: #d1d5db; font-family: monospace; }

/* ---------- pop-in animation ---------- */
@keyframes pop-in {
    0%   { transform: scale(0.85); opacity: 0.75; }
    65%  { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(1);    opacity: 1; }
}
.pop-in {
    animation: pop-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ---------- App loading splash ---------- */
.app-loading {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    background: radial-gradient(circle at 50% 35%, #1a1140 0%, #121212 70%);
}
.app-loading-dice {
    font-size: 4.5rem;
    animation: dice-tumble 1.4s cubic-bezier(0.5, 0.05, 0.4, 1) infinite;
    filter: drop-shadow(0 6px 18px rgba(96, 165, 250, 0.35));
}
.app-loading-text {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: linear-gradient(to right, #60a5fa, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.app-loading-dots span {
    display: inline-block;
    animation: loading-dot 1.2s ease-in-out infinite;
}
.app-loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.app-loading-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes dice-tumble {
    0%   { transform: translateY(0) rotate(0deg); }
    50%  { transform: translateY(-14px) rotate(180deg); }
    100% { transform: translateY(0) rotate(360deg); }
}
@keyframes loading-dot {
    0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
    30%           { opacity: 1;    transform: translateY(-3px); }
}

/* ---------- Error page ---------- */
.text-danger { color: #e50000; }

/* ---------- Blazor framework error UI ---------- */
#blazor-error-ui {
    color-scheme: dark;
    background: #2a1a00;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}
