/* Organic background */
body {
    margin: 0;
    padding: 0;
    font-family: 'Lato', sans-serif;
    background: #2e7d32 radial-gradient(circle at center, #a8e6cf, #dcedc1);
    color: #333;
}
/* Full-screen particles canvas */
#particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}
/* Main container */
.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 85vh;
    text-align: center;
    padding: 20px;
    gap: 60px;
}
h1 {
    font-family: 'Montserrat', sans-serif;
    font-size: 3em;
    margin-bottom: 30px;
    color: #2e7d32;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    line-height: 1.1em;
}
h1 span {
    font-size: 0.7em;
    color: #43a047;
}
/* Gate button styling with ripple effect */
#gate-button {
    position: relative;
    width: 250px;
    height: 250px;
    border-radius: 50%;
    background: linear-gradient(145deg, #66bb6a, #43a047);
    box-shadow: 0 10px 20px rgba(0,0,0,0.15);
    border: none;
    outline: none;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.5s ease;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}
#gate-button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 12px 24px rgba(0,0,0,0.2);
}
#gate-button:active:not(:disabled) {
    transform: scale(0.95);
    box-shadow: 0 5px 10px rgba(0,0,0,0.1);
}
/* Ripple effect via pseudo-element */
#gate-button::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.55);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    pointer-events: none;
    z-index: 1;
}
/* Ripple animation when .ripple class is added */
#gate-button.ripple::after {
    animation: rippleEffect 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes rippleEffect {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0.6;
    }
    100% {
        transform: translate(-50%, -50%) scale(9);
        opacity: 0;
    }
}
/* Icon container inside the button */
#icon-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -60%);
    width: 60%;
    height: 60%;
    pointer-events: none;
}
/* Each icon is absolutely positioned and hidden by default */
.icon {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
}
/* The visible icon */
.icon.visible {
    display: block;
}
.icon svg {
    height: 100%;
    width: 100%;
    color: #ffffff;
}
/* Gate label overlay below the icon */
#gate-label {
    position: absolute;
    bottom: 17%;
    left: 0;
    width: 100%;
    text-align: center;
    font-family: 'Montserrat', sans-serif;
    font-size: 1.4em;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    pointer-events: none;
    transition: opacity 0.3s ease;
}
/* --- Command feedback: progress ring, pending state, confirmation pill --- */
#gate-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}
/* Progress ring sweeping the button rim while a command is pending */
#progress-ring {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.35s ease;
    z-index: 2;
}
#gate-button.pending #progress-ring,
#gate-button.resolving #progress-ring {
    opacity: 1;
}
#progress-ring circle {
    fill: none;
}
#progress-ring-track {
    stroke: rgba(255, 255, 255, 0.18);
    stroke: oklch(1 0 0 / 0.18);
    stroke-width: 4;
}
#progress-ring-bar {
    stroke: #eafff3;
    stroke: oklch(0.98 0.035 150);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 289.0265;
    stroke-dashoffset: 289.0265;
    filter: drop-shadow(0 0 4px rgba(175, 240, 200, 0.65));
    filter: drop-shadow(0 0 4px oklch(0.95 0.10 150 / 0.65));
}
#gate-button.resolving #progress-ring-bar {
    filter: drop-shadow(0 0 10px rgba(190, 250, 210, 0.95));
    filter: drop-shadow(0 0 10px oklch(0.97 0.13 150 / 0.95));
}
#gate-button.resolving #progress-ring {
    animation: ringComplete 0.5s ease-out;
}
@keyframes ringComplete {
    0%   { transform: rotate(-90deg) scale(1); }
    45%  { transform: rotate(-90deg) scale(1.035); }
    100% { transform: rotate(-90deg) scale(1); }
}
/* Button while locked + pending */
#gate-button.pending {
    cursor: progress;
    box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.14), 0 8px 18px rgba(0, 0, 0, 0.14);
}
#gate-button.pending .icon.visible {
    opacity: 0.5;
    transition: opacity 0.3s ease;
}
/* One-shot press pop */
#gate-button.pressing {
    animation: pressPop 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes pressPop {
    0%   { transform: scale(1); }
    35%  { transform: scale(0.93); }
    100% { transform: scale(1); }
}
/* Confirmation pill below the button */
.gate-pill {
    position: absolute;
    top: 100%;
    left: 50%;
    margin-top: 22px;
    transform: translate(-50%, 8px);
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 9px 18px;
    border-radius: 999px;
    background: #f6fcf8;
    background: oklch(0.99 0.012 150);
    color: #2e6b3f;
    color: oklch(0.42 0.10 150);
    font-family: 'Lato', sans-serif;
    font-size: 0.98rem;
    letter-spacing: 0.01em;
    white-space: nowrap;
    box-shadow: 0 6px 20px rgba(40, 90, 60, 0.20);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 3;
}
.gate-pill.show {
    opacity: 1;
    transform: translate(-50%, 0);
}
.gate-pill-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #43a047;
    background: oklch(0.62 0.15 150);
    flex: none;
}
.gate-pill.sending .gate-pill-dot {
    animation: pillDot 1s ease-in-out infinite;
}
@keyframes pillDot {
    0%, 100% { transform: scale(0.65); opacity: 0.55; }
    50%      { transform: scale(1);    opacity: 1; }
}
.gate-pill.error {
    background: #fdeceb;
    background: oklch(0.97 0.035 25);
    color: #b3382f;
    color: oklch(0.52 0.16 25);
}
.gate-pill.error .gate-pill-dot {
    background: #e05547;
    background: oklch(0.60 0.20 25);
    animation: none;
}
/* Honor reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
    #gate-button.pressing { animation: none; }
    #gate-button.resolving #progress-ring { animation: none; }
    #gate-button.ripple::after { animation: none; }
    .gate-pill.sending .gate-pill-dot { animation: none; }
}
/* Error and token form styling */
.error {
    color: #c5312d;
    font-size: 1.3em;
    margin: 0;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
form.token-form {
    display: none;
}
form.token-form label {
    font-size: 1.2em;
    margin-bottom: 16px;
    display: block;
}
form.token-form input {
    padding: 12px;
    font-size: 1em;
    width: 250px;
    max-width: 90%;
    margin-bottom: 16px;
    display: block;
    border: 1px solid #2e7d32;
    border-radius: 8px;
    text-align: center;
}
form.token-form input::placeholder {
    color: #aaa;
}
form.token-form button {
    padding: 12px 32px;
    font-size: 1em;
    background: #43a047;
    color: #fff;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s ease;
}
form.token-form button:hover {
    background: #388e3c;
}
#footer {
    position: absolute;
    bottom: 2%;
    color: #2e7d32;
}