/* =========================================================================
   CAT GOLF 95 — design system
   Old-Windows golf-game manual cover meets modern goofy-cat internet.
   One accent (hot pink, not teal). One icon family (Unicode glyphs).
   Two-deep container nesting maximum.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&family=DotGothic16&family=VT323&display=swap');

:root {
    /* Palette — plum sunset over peach */
    --bg:           #ffd9c7;
    --bg-band-1:    #ff8aa3;
    --lavender:    #b779cf;
    --surface:      #fff6d3;
    --surface-2:    #ffe9cc;
    --plum:         #3d1f4d;
    --plum-2:       #5d3478;
    --lavender:     #9d6db5;
    --accent:       #ff3d6b;   /* the one accent — bold, not teal */
    --warm: #ecb217;
    --text:         #2a1a3a;
    --text-dim:     #6b5577;
    --text-invert:  #fff6d3;
    --border:       #3d1f4d;
    --border-soft:  #d8b3c8;
    --shadow-color: #46425e;
    --danger:       #c20a1f;
    --status-waiting: #f9c842;
    --status-playing: var(--accent);

    /* Type */
    --font-body:  "MS PGothic", "Atkinson Hyperlegible", Verdana, Helvetica, sans-serif;
    --font-pixel: "DotGothic16", "MS PGothic", monospace;
    --font-mono:  "VT323", "Courier New", monospace;
    --fs-body:    15px;
    --lh-body:    1.5;

    /* Spacing & shape */
    --gap:        12px;
    --pad:        14px;
    --radius:     4px;
    --topbar-h:   58px;

    /* Surfaces */
    --shadow-window: 4px 4px 0 var(--shadow-color);
    --shadow-tile:   2px 2px 0 var(--shadow-color);
}

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

body {
    font-family: var(--font-body);
    font-size: var(--fs-body);
    line-height: var(--lh-body);
    color: var(--text);
    background-color: var(--bg);
    background-image:
        repeating-linear-gradient(45deg, transparent 0 10px, rgba(255,255,255,0.10) 10px 20px),
        radial-gradient(circle at 0% 0%, var(--bg-band-1), transparent 55%),
        radial-gradient(circle at 100% 100%, var(--bg-band-2), transparent 55%);
    background-attachment: fixed;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--plum); outline-offset: 2px; }

/* ---------- Top bar (nav stays at the top) ---------- */
.top-bar {
    background: linear-gradient(180deg, var(--plum) 0 70%, var(--plum-2));
    border-bottom: 3px solid var(--accent);
    color: var(--text-invert);
    padding: 8px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    min-height: var(--topbar-h);
}

.top-bar .logo {
    margin: 0;
    font-family: var(--font-pixel);
    font-size: 18px;
    letter-spacing: 0.06em;
    color: var(--text-invert);
    flex: 0 0 auto;
    background: var(--accent);
    padding: 4px 12px;
    border: 2px solid var(--surface);
    box-shadow: var(--shadow-tile);
}
.top-bar .logo a { color: inherit; text-decoration: none; }

.main-nav { flex: 1 1 auto; min-width: 0; }
.main-nav ul {
    list-style: none; margin: 0; padding: 0;
    display: flex; gap: 2px; flex-wrap: wrap;
}
.main-nav a {
    display: block;
    padding: 5px 10px;
    font-family: var(--font-pixel);
    font-size: 13px;
    color: var(--text-invert);
    border: 1px solid transparent;
    border-radius: 3px;
}
.main-nav a:hover {
    background: var(--accent);
    border-color: var(--text-invert);
    text-decoration: none;
}
.main-nav a .count {
    display: inline-block;
    background: var(--accent);
    color: var(--text-invert);
    padding: 0 6px;
    margin-left: 4px;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 16px;
}

.user-area {
    display: flex; align-items: center; gap: 10px;
    flex: 0 0 auto;
}
.user-area .who {
    font-family: var(--font-pixel);
    font-size: 12px;
    color: var(--surface);
    opacity: 0.85;
}

.guest-links { display: flex; gap: 6px; flex: 0 0 auto; }

/* Buttons that live on the dark top bar */
.top-bar form { display: inline; margin: 0; }
.top-bar .logout-btn,
.top-bar .pill-btn {
    background: transparent;
    border: 1px solid var(--text-invert);
    color: var(--text-invert);
    padding: 4px 10px;
    font-family: var(--font-pixel);
    font-size: 11px;
    cursor: pointer;
    border-radius: 3px;
    text-decoration: none;
}
.top-bar .logout-btn:hover,
.top-bar .pill-btn:hover { background: var(--accent); border-color: var(--accent); }

/* ---------- Page ---------- */
.page {
    max-width: 1080px;
    margin: 18px auto 32px;
    padding: 0 14px;
}

/* ---------- Window component (1st level) ---------- */
.window {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-window);
    margin-bottom: 18px;
    overflow: hidden;
    color: var(--text);
}
.window > .titlebar {
    background: linear-gradient(90deg, var(--plum) 0%, var(--accent) 110%);
    color: var(--text-invert);
    padding: 7px 12px;
    font-family: var(--font-pixel);
    font-size: 13px;
    letter-spacing: 0.06em;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.window > .titlebar .meta {
    font-family: var(--font-mono);
    font-size: 14px;
    letter-spacing: 0;
    background: rgba(0,0,0,0.18);
    padding: 0 8px;
    border-radius: 3px;
}
.window > .body { padding: var(--pad); }

/* Headings inside .body — pixel face */
.body > h1, .body > h2, .body > h3, .body > h4 {
    font-family: var(--font-pixel);
    margin: 18px 0 8px;
    color: var(--plum);
    letter-spacing: 0.04em;
}
.body > h1:first-child, .body > h2:first-child,
.body > h3:first-child, .body > h4:first-child { margin-top: 0; }
.body > h2 { font-size: 17px; }
.body > h3 { font-size: 15px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-pixel);
    font-size: 13px;
    letter-spacing: 0.04em;
    padding: 7px 14px;
    border: 2px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    box-shadow: var(--shadow-tile);
    border-radius: 2px;
    transition: transform 0.06s ease-out, box-shadow 0.06s ease-out;
}
.btn:hover  { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--shadow-color); text-decoration: none; }
.btn:active { transform: translate(2px, 2px); box-shadow: none; }

.btn-primary { background: var(--accent); color: var(--text-invert); }
.btn-ghost   { background: transparent; box-shadow: none; border-color: var(--border-soft); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-warm    { background: var(--warm); color: var(--plum); }
.btn-sm      { padding: 4px 8px; font-size: 11px; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
form .field { margin-bottom: 14px; }

form label {
    display: block;
    font-family: var(--font-pixel);
    font-size: 12px;
    letter-spacing: 0.06em;
    color: var(--plum);
    margin-bottom: 4px;
    text-transform: uppercase;
}

/* The single semantic role for "decoration": REQUIRED markers.
   Optional fields get NO label suffix; required ones get a red asterisk. */
form label.required::after,
form .field.required > label::after {
    content: " *";
    color: var(--danger);
    font-weight: bold;
    font-family: var(--font-body);
}

form input[type="text"],
form input[type="email"],
form input[type="password"],
form input[type="number"],
form input[type="search"],
form select,
form textarea {
    font-family: var(--font-body);
    font-size: 14px;
    padding: 8px 10px;
    border: 2px inset var(--border-soft);
    background: #fff;
    color: var(--text);
    border-radius: 2px;
    width: 100%;
    max-width: 320px;
}
form input[type="text"]:focus,
form input[type="email"]:focus,
form input[type="password"]:focus,
form input[type="number"]:focus,
form select:focus,
form textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 0;
    background: var(--surface);
}

form input[type="checkbox"] {
    accent-color: var(--accent);
    width: auto;
}

form .errorlist,
form ul.errorlist {
    list-style: none;
    margin: 4px 0 8px;
    padding: 6px 10px;
    background: #ffe6e6;
    border-left: 4px solid var(--danger);
    font-size: 13px;
    color: var(--danger);
    font-family: var(--font-body);
    text-transform: none;
    letter-spacing: 0;
}
form p { margin: 8px 0; }

/* ---------- Tables ---------- */
table.list {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: var(--surface);
}
table.list th,
table.list td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}
table.list th {
    background: var(--plum);
    color: var(--text-invert);
    font-family: var(--font-pixel);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-bottom-color: var(--border);
}
table.list tr:nth-child(even) td { background: var(--surface-2); }
table.list tr:hover td { background: rgba(255, 61, 107, 0.08); }
table.list .num { font-family: var(--font-mono); font-size: 16px; }

/* ---------- Django messages ---------- */
.messages { margin-bottom: 14px; }
.messages .msg {
    padding: 8px 12px;
    background: var(--surface);
    border: 2px solid var(--accent);
    border-left-width: 6px;
    font-size: 13px;
    margin-bottom: 6px;
    border-radius: 2px;
}

/* ---------- Lobby list rows ---------- */
.lobby-row {
    display: grid;
    grid-template-columns: 44px 1fr auto auto;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    background: var(--surface);
    border: 1.5px solid var(--border-soft);
    margin-bottom: 8px;
    border-radius: 3px;
    text-decoration: none;
    color: var(--text);
}
.lobby-row:hover { background: var(--surface-2); border-color: var(--border); text-decoration: none; }

/* status sigil — old-Windows-y bevel */
.status-sigil {
    width: 36px; height: 36px;
    border: 2px solid var(--border);
    border-radius: 3px;
    box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 var(--shadow-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-pixel);
    font-size: 16px;
    color: var(--plum);
}
.status-sigil.waiting { background: var(--status-waiting); }
.status-sigil.playing { background: var(--status-playing); color: var(--text-invert); }

.lobby-row .name {
    font-family: var(--font-pixel);
    font-size: 14px;
    letter-spacing: 0.04em;
    color: var(--plum);
    margin-bottom: 2px;
}
.lobby-row .who {
    font-size: 12px;
    color: var(--text-dim);
}

/* slot pips — visual representation of "X of N players" */
.slot-pips {
    display: flex;
    gap: 3px;
    margin-right: 6px;
}
.slot-pip {
    width: 12px; height: 12px;
    border: 1.5px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
}
.slot-pip.here { background: var(--accent); }
.slot-pip.away { background: repeating-linear-gradient(45deg, var(--accent) 0 3px, var(--surface) 3px 6px); }

/* ---------- Chat — lobby tint as background, hashed username color ---------- */
#chat-log .msg,
.chat-message {
    padding: 4px 8px;
    margin: 3px 0;
    border-radius: 4px;
    font-size: 13px;
    word-break: break-word;
    background: var(--surface);
    border-left: 3px solid transparent;
}
#chat-log .msg .username,
.chat-message .username {
    font-weight: bold;
    font-family: var(--font-pixel);
    font-size: 12px;
}
#chat-log .msg .time,
.chat-message .time {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--lavender);
    margin-left: 4px;
}
#chat-log .msg.in-game {
    color: var(--surface);
}


.chat-message.is-me {
    border-left-color: var(--accent);
}

/* ---------- In-game player roster pill ---------- */
.mp-player {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 6px;
    border-radius: 3px;
    color: var(--surface);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.mp-player:last-child { border-bottom: none; }
.mp-player.is-you { background: rgba(255, 61, 107, 0.18); }
.mp-player.disconnected { opacity: 0.45; }

.mp-pid {
    width: 22px; height: 22px;
    flex: 0 0 22px;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-pixel);
    font-size: 11px;
    border: 1.5px solid #fff;
    border-radius: 3px;
    color: #2a1a3a;
    font-weight: bold;
}
.mp-name { flex: 1; font-weight: bold; }
.mp-name small { opacity: 0.75; font-weight: normal; }
.mp-role { font-size: 10px; opacity: 0.7; font-family: var(--font-pixel); }

/* ---------- Cat-sticker accents (decorative, pure type) ---------- */
.cat-sticker {
    display: inline-block;
    transform: rotate(-6deg);
    background: var(--warm);
    color: var(--plum);
    border: 2px solid var(--border);
    padding: 2px 8px;
    font-family: var(--font-pixel);
    font-size: 11px;
    letter-spacing: 0.06em;
    box-shadow: var(--shadow-tile);
}

/* ---------- Hero / landing helpers ---------- */
.hero {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    align-items: stretch;
}
.hero .hero-text { padding: var(--pad); }
.hero h1 {
    font-family: var(--font-pixel);
    font-size: 28px;
    letter-spacing: 0.05em;
    margin: 0 0 6px;
    color: var(--plum);
}
.hero .tagline {
    font-family: var(--font-mono);
    font-size: 18px;
    color: var(--accent);
    margin: 0 0 14px;
}
.hero p { margin: 8px 0; }

.hero-card {
    background:
        linear-gradient(170deg, var(--accent) 0 30%, var(--warm));
    border: 2px solid var(--border);
    color: var(--text-invert);
    padding: 16px;
    font-family: var(--font-pixel);
    font-size: 14px;
    line-height: 1.7;
    box-shadow: var(--shadow-tile);
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: center;
}
.hero-card .quick-row {
    display: flex; gap: 6px; flex-wrap: wrap;
}

/* Stat ribbon (used on home / profile) */
.stats-ribbon {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0;
}
.stat-tile {
    flex: 1 1 140px;
    background: var(--surface-2);
    border: 1.5px solid var(--border-soft);
    border-radius: 3px;
    padding: 10px 12px;
}
.stat-tile .label {
    font-family: var(--font-pixel);
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    text-transform: uppercase;
}
.stat-tile .value {
    font-family: var(--font-mono);
    font-size: 24px;
    color: var(--plum);
}

/* Generic empty state */
.empty {
    padding: 28px 16px;
    text-align: center;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 18px;
    border: 2px dashed var(--border-soft);
    border-radius: 4px;
    margin: 8px 0;
    background: var(--surface);
}

/* Inline meta text (under titles, etc.) */
.meta-line {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-dim);
}
.meta-line strong { color: var(--text); }

/* Pixel divider */
.pixel-rule {
    border: 0;
    height: 6px;
    background-image: linear-gradient(90deg, var(--plum) 0 6px, transparent 6px 12px);
    background-size: 12px 6px;
    margin: 14px 0;
}

/* ---------- Friend / notification list ---------- */
.row-list { list-style: none; margin: 0; padding: 0; }
.row-list .row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface);
}
.row-list .row:nth-child(even) { background: var(--surface-2); }
.row-list .row:last-child { border-bottom: none; }
.row-list .row .grow { flex: 1; }
.row-list .row .when { font-family: var(--font-mono); font-size: 14px; color: var(--text-dim); }

/* Notification not-yet-read marker (single-role left rule) */
.notif.unread {
    border-left: 4px solid var(--accent);
    background: var(--surface-2);
}
.notif .title { font-family: var(--font-pixel); font-size: 13px; letter-spacing: 0.04em; color: var(--plum); }

/* ---------- Multiplayer in-game side panels ---------- */
.game-wrapper {
    width: 80%;
    height: calc(100vh - var(--topbar-h));
    background: var(--plum);
    display: flex;
    flex-direction: row;
    overflow: hidden;
}
.game-area {
    position: relative;
    flex: 0 0 100%;
    background: #000;
    overflow: hidden;
}
.game-area iframe {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    border: none;
}

#mp-panel {
    position: absolute;
    top: 8px; right: 8px;
    z-index: 20;
    background: var(--plum);
    opacity: 0.7;
    color: var(--text-invert);
    border: 2px solid var(--border);
    box-shadow: var(--shadow-tile);
    border-radius: var(--radius);
    min-width: 180px;
    max-width: 300px;
    overflow: hidden;
    font-family: var(--font-body);
    transform: scale(0.85);
    transform-origin: top right;
}
#mp-panel .titlebar {
    background: linear-gradient(90deg, var(--plum-2), var(--accent));
    color: var(--text-invert);
    padding: 5px 10px;
    font-family: var(--font-pixel);
    font-size: 12px;
    letter-spacing: 0.06em;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
#mp-panel .body { padding: 6px 8px; }
#mp-panel .controls-hint {
    margin-top: 6px; padding-top: 6px;
    border-top: 1px dashed rgba(255,255,255,0.18);
    font-size: 11px;
    color: var(--surface);
    opacity: 0.8;
}
kbd {
    display: inline-block;
    background: var(--plum);
    color: var(--text-invert);
    border: 1px solid var(--surface);
    padding: 0 5px;
    font-family: var(--font-mono);
    font-size: 13px;
    border-radius: 2px;
}

#mp-toasts {
    position: absolute;
    top: 12px; left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    display: flex; flex-direction: column; gap: 6px;
    pointer-events: none;
}
.mp-toast {
    background: var(--plum);
    color: var(--text-invert);
    border: 2px solid var(--accent);
    padding: 6px 12px;
    font-family: var(--font-pixel);
    font-size: 12px;
    box-shadow: var(--shadow-tile);
}
.mp-toast.info { border-color: var(--warm); }

#mp-debug {
    position: absolute; bottom: 8px; left: 8px;
    max-width: 480px;
    max-height: 200px;
    overflow: auto;
    background: rgba(0,0,0,0.78);
    color: #d6f5ff;
    font-family: var(--font-mono);
    font-size: 13px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 3px;
    z-index: 25;
    pointer-events: none;
    white-space: pre-wrap;
}
#mp-debug .err { color: #ff7b7b; }
#mp-debug .ok  { color: #8aff8a; }

/* In-game side chat */
#global-chat-panel {
    flex: 0 0 20%;
    width: 20%;
    height: 100%;
    background: var(--plum);
    color: var(--surface);
    display: flex;
    flex-direction: column;
    border-left: 2px solid var(--border);
}
#global-chat-panel h4 {
    margin: 0;
    padding: 7px 10px;
    background: linear-gradient(90deg, var(--plum-2), var(--accent));
    color: var(--text-invert);
    font-family: var(--font-pixel);
    font-size: 13px;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
}
#chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
    line-height: 1.45;
    background: linear-gradient(180deg, var(--plum) 0%, #2a1438 100%);
}
#chat-log .msg {
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
}
#chat-log .msg .username { font-family: var(--font-body); font-size: 12px; }
#chat-form {
    display: flex; gap: 4px;
    padding: 6px;
    border-top: 1px solid var(--border);
    background: var(--plum-2);
}
#chat-form input {
    flex: 1;
    background: var(--surface);
    border: 1.5px inset var(--border-soft);
    color: var(--text);
    padding: 4px 6px;
    border-radius: 2px;
    font-size: 13px;
    outline: none;
    max-width: none;
    font-family: var(--font-body);
}
#chat-form input:focus { background: #fff; outline: 2px solid var(--accent); }
#chat-form button {
    background: var(--accent);
    color: var(--text-invert);
    border: 1.5px solid var(--border);
    padding: 4px 10px;
    font-family: var(--font-pixel);
    font-size: 11px;
    border-radius: 2px;
    cursor: pointer;
}
#chat-form button:hover { background: var(--warm); color: var(--plum); }

/* ---------- Avatars ---------- */
.avatar {
    display: inline-block;
    flex-shrink: 0;
    object-fit: cover;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 1px 1px 0 var(--shadow-color);
    vertical-align: middle;
    overflow: hidden;
    line-height: 1;
}
.avatar-xs { width: 16px;  height: 16px;  font-size: 10px; }
.avatar-sm { width: 22px;  height: 22px;  font-size: 12px; }
.avatar-md { width: 36px;  height: 36px;  font-size: 16px; }
.avatar-lg { width: 96px;  height: 96px;  font-size: 36px; }
.avatar-xl { width: 160px; height: 160px; font-size: 64px; }
.avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-pixel);
    font-weight: 700;
    color: var(--text-invert);
    background: var(--plum-2);
    text-transform: uppercase;
    user-select: none;
}
/* Inline avatar inside chat / row contexts — sit tight to the username */
.avatar-inline {
    margin-right: 6px;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.001s !important; transition: none !important; }
}

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
    .top-bar { padding: 6px 10px; }
    .top-bar .logo { font-size: 16px; }
    .main-nav a { font-size: 12px; padding: 4px 7px; }
    .hero { grid-template-columns: 1fr; }
    .lobby-row { grid-template-columns: 36px 1fr auto; }
    .lobby-row .who { display: none; }
    .game-area { flex: 0 0 65%; width: 65%; }
    #global-chat-panel { flex: 0 0 35%; width: 35%; }
}
