/* ---------- Font ---------- */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Noto+Color+Emoji&display=swap');

/* ---------- Colors (change them here and the whole game changes) ---------- */
:root {
    --nori: #0f1f1a;       /* background */
    --nori-light: #183029; /* slightly lighter, for depth */
    --rice: #f6f3ea;       /* text */
    --rice-muted: #b9c2bb; /* quieter text */
    --salmon: #ff7a4d;     /* main buttons */
    --salmon-dark: #e55f32;
    --wasabi: #b7e05a;     /* focus ring and points */
    --soy: #2a1b16;        /* dark text on salmon */
}

/* ---------- Page ---------- */
* {
    box-sizing: border-box;
}

/* Solid color behind everything, so you never see white when scrolling or overscrolling */
html {
    background-color: var(--nori);
}

body {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(to bottom, var(--nori-light), var(--nori));
    color: var(--rice);
    font-family: 'Fredoka', 'Noto Color Emoji', system-ui, sans-serif;
    font-size: 18px;
    line-height: 1.4;
}

/* ---------- Screens ---------- */
.screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    min-height: 100vh;
    padding: 32px 20px;
    text-align: center;
}

/* Must stay AFTER .screen so it wins over display: flex */
.hidden {
    display: none;
}

/* ---------- Text ---------- */
h1 {
    margin: 0;
    font-size: clamp(2rem, 7vw, 2.8rem);
    font-weight: 700;
    line-height: 1.1;
}

h2 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--rice-muted);
}

h3 {
    margin: 0 0 4px;
    font-size: 1.4rem;
    font-weight: 600;
}

h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--rice-muted);
}

p {
    margin: 0;
    color: var(--rice-muted);
}

#login-error {
    color: #ff9c9c;
    min-height: 1.4em;
}

/* The big number: points */
#score {
    display: block;
    font-size: clamp(3.5rem, 16vw, 5rem);
    font-weight: 700;
    line-height: 1.1;
    color: var(--wasabi);
}

.logo {
    width: 150px;
    height: auto;
    border-radius: 28px; /* softens the logo's white square */
}

/* ---------- Buttons ---------- */
button {
    font-family: inherit;
    font-size: 1.15rem;
    font-weight: 600;
    padding: 14px 28px;
    border: 2px solid transparent;
    border-radius: 999px;
    background: var(--salmon);
    color: var(--soy);
    cursor: pointer;
    transition: transform 0.12s ease, background-color 0.12s ease;
}

.screen > button,
.counter > button {
    width: min(100%, 320px);
}

button:active {
    transform: scale(0.96);
}

button:focus-visible {
    outline: 3px solid var(--wasabi);
    outline-offset: 3px;
}

@media (hover: hover) {
    button:hover {
        background: var(--salmon-dark);
    }
}

/* Quiet buttons: going back / signing out */
#logout-btn,
.quiet,
[data-goto="menu-screen"] {
    background: transparent;
    color: var(--rice);
    border-color: rgba(246, 243, 234, 0.35);
}

@media (hover: hover) {
    #logout-btn:hover,
    .quiet:hover,
    [data-goto="menu-screen"]:hover {
        background: rgba(246, 243, 234, 0.1);
    }
}

/* ---------- Game layout: nigiri on the left, store on the right ---------- */
#game-screen {
    padding: 24px 20px;
}

.game-layout {
    width: min(100%, 1100px);
    display: grid;
    grid-template-columns: 1fr;   /* phones: stacked */
    gap: 28px;
    align-items: center;
}

.counter {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
}

/* Wide screens: two columns */
@media (min-width: 900px) {
    .game-layout {
        grid-template-columns: 320px 1fr;
    }
}

/* ---------- The factory ---------- */
.factory {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px;
    border-radius: 24px;
    background: rgba(246, 243, 234, 0.06);
    text-align: left;
}

/* The row of pieces you can pick */
#toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tool {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    min-width: 74px;
    padding: 8px 8px;
    border: 2px solid rgba(246, 243, 234, 0.2);
    border-radius: 12px;
    background: var(--nori-light);
    color: var(--rice);
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.2;
}

.tool-emoji {
    font-size: 1.5rem;
    line-height: 1.2;
}

.tool-cost {
    color: var(--wasabi);
    font-weight: 600;
}

/* Can't afford it right now (you can still select it) */
.tool.poor .tool-cost {
    color: #ff9c9c;
}

.tool.selected {
    border-color: var(--salmon);
    background: #234438;
}

@media (hover: hover) {
    .tool:hover {
        background: #234438;
    }
}

/* The factory floor. app.js sets the real size; CSS scales it to fit the panel. */
#factory-canvas {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 14px;
    cursor: pointer;
    touch-action: manipulation;
}

.factory-help {
    font-size: 0.9rem;
    line-height: 1.5;
}

.factory-message {
    min-height: 1.4em;
    font-size: 0.9rem;
    color: var(--salmon);
}

/* ---------- Chopsticks button (under the nigiri) ---------- */
.chopsticks-btn {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 16px;
    border: 2px dashed var(--salmon);
    background: transparent;
    color: var(--rice);
    font-size: 1rem;
    line-height: 1.3;
}

.chopsticks-title {
    font-weight: 600;
}

.chopsticks-title #chopsticks-count {
    color: var(--wasabi);
}

.chopsticks-detail {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--rice-muted);
}

@media (hover: hover) {
    .chopsticks-btn:not(:disabled):hover {
        background: rgba(255, 122, 77, 0.18);
    }
}

.chopsticks-btn:disabled {
    opacity: 0.45;
    border-color: rgba(246, 243, 234, 0.35);
    cursor: not-allowed;
}

.chopsticks-btn:disabled:active {
    transform: none;
}

/* ---------- The nigiri: the big click button ---------- */
#click-btn {
    width: min(86vw, 300px);
    height: 170px;
    margin: 8px 0;
    border: none;
    border-radius: 999px 999px 90px 90px / 110px 110px 60px 60px;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--soy);

    /* Put the text at the bottom, on the rice part */
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0 0 22px;

    /* Layer 1: salmon on top. Layer 2: rice underneath. */
    background:
        /* fat stripes on the salmon */
        repeating-linear-gradient(
            100deg,
            rgba(255, 255, 255, 0.28) 0 6px,
            transparent 6px 26px
        ) top / 100% 60% no-repeat,
        linear-gradient(to bottom, #ff9566, #ff6a3d) top / 100% 60% no-repeat,
        /* the rice */
        radial-gradient(ellipse at 50% 90%, #ffffff, #e9e4d4);

    box-shadow: 0 10px 0 #b8b2a0, 0 22px 28px rgba(0, 0, 0, 0.4);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

@media (hover: hover) {
    #click-btn:hover {
        background:
            repeating-linear-gradient(
                100deg,
                rgba(255, 255, 255, 0.28) 0 6px,
                transparent 6px 26px
            ) top / 100% 60% no-repeat,
            linear-gradient(to bottom, #ff9566, #ff6a3d) top / 100% 60% no-repeat,
            radial-gradient(ellipse at 50% 90%, #ffffff, #e9e4d4);
    }
}

/* Pressing it pushes it down into the "plate" */
#click-btn:active {
    transform: translateY(8px) scale(0.99);
    box-shadow: 0 2px 0 #b8b2a0, 0 8px 14px rgba(0, 0, 0, 0.4);
}

/* ---------- The "+1" that floats up when you click ---------- */
.float {
    position: fixed;
    transform: translate(-50%, -50%);
    pointer-events: none;   /* so it never blocks your next click */
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--wasabi);
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    animation: float-up 0.8s ease-out forwards;
}

@keyframes float-up {
    from { opacity: 1; margin-top: 0; }
    to   { opacity: 0; margin-top: -70px; }
}

/* ---------- Respect people who turn animations off ---------- */
@media (prefers-reduced-motion: reduce) {
    button {
        transition: none;
    }

    .float {
        display: none;
    }
}

/* ---------- Shop and inventory ---------- */
.panel {
    width: min(100%, 560px);
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 22px;
    border-radius: 24px;
    background: rgba(246, 243, 234, 0.06);
}

.points-text {
    color: var(--wasabi);
    font-weight: 700;
}

.buy-amount {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--rice-muted);
}

.amount-btn {
    padding: 6px 16px;
    font-size: 1rem;
    background: transparent;
    color: var(--rice);
    border-color: rgba(246, 243, 234, 0.35);
}

.amount-btn.selected {
    background: var(--salmon);
    color: var(--soy);
    border-color: var(--salmon);
}

.item-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 16px;
    background: var(--nori-light);
    text-align: left;
}

.item-emoji {
    font-size: 1.8rem;
    line-height: 1;
}

.item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.item-name {
    font-weight: 600;
}

.item-sub {
    font-size: 0.85rem;
    color: var(--rice-muted);
}

.item-buy {
    padding: 8px 16px;
    font-size: 0.95rem;
    white-space: nowrap;
}

.item-buy:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.item-buy:disabled:active {
    transform: none;
}

.item-counts {
    display: flex;
    gap: 14px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--rice-muted);
}

.item-counts b {
    display: block;
    font-size: 1.2rem;
    color: var(--rice);
}

.item-counts .total b {
    color: var(--wasabi);
}
