:root {
    --bg:    #f6c70c;
    --ink:   #2a1c08;     /* dark warm brown for body text */
    --ink-2: #5a4418;
    --paper: #fffaeb;     /* card cream */
    --line:  #1a1208;     /* near-black borders */
    --hi:    #ffe45c;     /* highlight yellow */
  }

  * { box-sizing: border-box; }

  html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "DotGothic16", "Hiragino Maru Gothic ProN", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
  }

  body {
    min-height: 100vh;
    padding-bottom: clamp(80px, 10vh, 140px);
  }

  a { color: inherit; }

  /* ── Header ────────────────────────────────────── */
  .header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: clamp(16px, 2.4vw, 32px) clamp(20px, 3vw, 44px);
    background:
      linear-gradient(180deg, var(--bg) 0%, var(--bg) 70%, rgba(246,199,12,0.0) 100%);
  }

  .site-brand {
    display: flex;
    align-items: center;
    gap: clamp(10px, 1.1vw, 18px);
    text-decoration: none;
    filter: drop-shadow(0 4px 0 rgba(0,0,0,0.12));
    transition: transform 0.15s ease;
  }
  .site-brand:hover { transform: translate(-1px, -1px); }

  .site-brand-logo {
    height: clamp(40px, 4.4vw, 62px);
    width: auto;
    display: block;
  }

  .nav {
    display: flex;
    align-items: center;
    gap: clamp(10px, 1vw, 18px);
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: clamp(12px, 1.2vw, 19px);
    letter-spacing: 0.06em;
    color: #fff;
  }
  .nav a {
    color: #fff;
    text-decoration: none;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.20);
    padding: 4px 2px;
    transition: transform 0.15s ease, color 0.15s ease;
  }
  .nav a:hover { transform: translate(-1px, -1px); color: #fff8d4; }
  .nav a.active {
    color: #96580b;
    text-shadow: 2px 2px 0 var(--hi);
  }
  .nav .sep { opacity: 0.85; }

  /* ── Page layout ───────────────────────────────── */
  .page {
    max-width: 880px;
    margin: 0 auto;
    padding: clamp(20px, 4vw, 56px) clamp(20px, 4vw, 32px) 0;
  }

  .page-head {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: clamp(20px, 3vw, 40px);
    margin: clamp(20px, 4vw, 48px) 0 clamp(30px, 5vw, 56px);
  }

  .page-title {
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: clamp(46px, 8.5vw, 80px);
    line-height: 0.95;
    color: #fff;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.20);
    letter-spacing: 0.02em;
    margin: 0 0 6px;
  }

  .page-sub {
    font-size: clamp(15px, 1.6vw, 20px);
    color: var(--ink);
    letter-spacing: 0.08em;
    margin: 0;
  }

  .page-doodle {
    width: clamp(110px, 14vw, 180px);
    height: auto;
    transform: rotate(-8deg) translateY(8px);
    filter: drop-shadow(0 8px 0 rgba(0,0,0,0.10));
  }

  /* ── RPG character (WASD / arrow keys to move) ─── */
  .rpg-char {
    position: fixed;
    /* JS sets --x, --y in px; start position assigned on init */
    --x: 0px;
    --y: 0px;
    --cell: 96px;            /* on-screen size (32px source × 3) */
    left: 0;
    top: 0;
    width: var(--cell);
    height: var(--cell);
    z-index: 30;
    pointer-events: none;
    /* sprite sheet: 3 cols × 4 rows of 32×32 cells */
    background-image: url('../img/rpg_chikuwa.png');
    background-repeat: no-repeat;
    background-size: calc(var(--cell) * 3) calc(var(--cell) * 4);
    background-position: 0 0;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    transform: translate(var(--x), var(--y)) translateY(var(--bob, 0px));
    filter: drop-shadow(0 6px 0 rgba(0,0,0,0.18));
    will-change: transform, background-position;
  }

  .rpg-hint {
    position: fixed;
    left: clamp(20px, 3vw, 44px);
    bottom: clamp(26px, 3vw, 44px);
    z-index: 11;
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: 9px;
    line-height: 1.7;
    letter-spacing: 0.04em;
    color: rgba(255,255,255,0.95);
    text-shadow: 2px 2px 0 rgba(0,0,0,0.20);
    pointer-events: none;
    text-align: left;
  }
  .rpg-hint .kbd {
    display: inline-block;
    border: 2px solid rgba(255,255,255,0.92);
    padding: 2px 5px;
    margin: 0 1px;
    border-radius: 3px;
    font-size: 8px;
  }

  /* ── Oden items (fixed overlay, same vibe as top) ── */
  .items {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 25;
  }
  .oden {
    position: absolute;
    transform: translate(-50%, -50%);
    font-size: clamp(36px, 3.6vw, 54px);
    line-height: 1;
    user-select: none;
    filter: drop-shadow(0 6px 6px rgba(0,0,0,0.18));
  }
  .oden .inner {
    display: inline-block;
    animation: odenBob 1.6s ease-in-out infinite;
    transform-origin: 50% 80%;
  }
  @keyframes odenBob {
    0%, 100% { transform: translateY(-4px) rotate(-4deg); }
    50%      { transform: translateY( 6px) rotate( 4deg); }
  }
  .oden.pop .inner {
    animation: odenPop 0.45s ease-out forwards;
  }
  @keyframes odenPop {
    0%   { transform: translateY(0)   scale(1)   rotate(0);    opacity: 1; }
    60%  { transform: translateY(-26px) scale(1.5) rotate(12deg); opacity: 1; }
    100% { transform: translateY(-54px) scale(1.7) rotate(20deg); opacity: 0; }
  }

  /* ── Credits (inline, end of page) ────────────────── */
  .credits {
    max-width: 880px;
    margin: clamp(20px, 2.6vw, 32px) auto 0;
    padding: 0 clamp(22px, 3vw, 38px);
    font-size: 12px;
    line-height: 1.7;
    letter-spacing: 0.02em;
    color: rgba(42,28,8,0.70);
    text-align: left;
  }
  .credits a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: rgba(42,28,8,0.35);
    text-underline-offset: 2px;
  }
  .credits a:hover { color: var(--line); text-decoration-color: var(--line); }

  /* ── Oden items on the page ───────────────── */
  .oden-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 25;
  }
  .oden {
    position: absolute;
    transform: translate(-50%, -50%);
    font-size: clamp(34px, 3.4vw, 50px);
    line-height: 1;
    filter: drop-shadow(0 4px 4px rgba(0,0,0,0.20));
  }
  .oden .inner {
    display: inline-block;
    animation: odenBob 1.6s ease-in-out infinite;
    transform-origin: 50% 80%;
  }
  @keyframes odenBob {
    0%, 100% { transform: translateY(-3px) rotate(-4deg); }
    50%      { transform: translateY( 5px) rotate( 4deg); }
  }
  .oden.pop .inner { animation: odenPop 0.45s ease-out forwards; }
  @keyframes odenPop {
    0%   { transform: translateY(0)    scale(1)   rotate(0);    opacity: 1; }
    60%  { transform: translateY(-26px) scale(1.5) rotate(14deg); opacity: 1; }
    100% { transform: translateY(-56px) scale(1.8) rotate(22deg); opacity: 0; }
  }

  /* ── Credit footer ─────────────────────────── */
  .credit {
    max-width: 880px;
    margin: clamp(40px, 6vw, 72px) auto 0;
    padding: 0 clamp(20px, 4vw, 32px);
    font-size: 12px;
    line-height: 1.8;
    letter-spacing: 0.02em;
    color: var(--ink-2);
    text-align: center;
  }
  .credit a {
    color: var(--line);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
  }

  /* ── Cards ─────────────────────────────────────── */
  .stack { display: flex; flex-direction: column; gap: clamp(20px, 2.6vw, 32px); }

  .card {
    background: var(--paper);
    border: 3px solid var(--line);
    border-radius: 8px;
    padding: clamp(20px, 2.6vw, 32px) clamp(22px, 3vw, 38px);
    box-shadow: 6px 6px 0 var(--line);
  }

  .card h2 {
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: clamp(14px, 1.4vw, 18px);
    margin: 0 0 clamp(14px, 1.6vw, 20px);
    letter-spacing: 0.06em;
    color: var(--line);
    display: inline-flex;
    align-items: center;
    gap: 10px;
  }
  .card h2::before {
    content: "";
    display: inline-block;
    width: 14px; height: 14px;
    background: var(--line);
    transform: rotate(45deg);
  }

  .card p,
  .card li,
  .card dd {
    font-size: clamp(15px, 1.4vw, 19px);
    line-height: 1.9;
    letter-spacing: 0.02em;
  }
  .card p { margin: 0 0 0.5em; text-wrap: pretty; }
  .card p:last-child { margin-bottom: 0; }

  .card:not(.profile) {
    position: relative;
    background: #050806;
    border: none;
    border-radius: 6px;
    color: #fff;
    box-shadow:
      0 0 0 2px #111,
      0 0 0 5px #ffffff,
      0 0 0 8px #111,
      6px 6px 0 rgba(0,0,0,0.25);
  }
  .card:not(.profile) h2 {
    color: #fff;
    text-shadow: 2px 2px 0 #000;
  }
  .card:not(.profile) h2::before {
    width: 9px;
    height: 9px;
    background: #d5a181;
    box-shadow: 1px 1px 0 #000;
  }
  .card:not(.profile) p,
  .card:not(.profile) li,
  .card:not(.profile) dd {
    color: #fff;
    text-shadow: 2px 2px 0 #000;
  }

  /* Profile card (avatar + handle) */
  .profile {
    display: grid;
    grid-template-columns: minmax(150px, 0.82fr) minmax(220px, 1.18fr);
    align-items: start;
    gap: clamp(22px, 4vw, 56px);
    position: relative;
    background: linear-gradient(135deg, #172b8f 0%, #1f5bd0 52%, #0b1d68 100%);
    border: 4px solid #f7f7ff;
    border-radius: 6px;
    color: #fff;
    box-shadow:
      0 0 0 2px #101338,
      0 0 0 5px #8396d0,
      6px 6px 0 rgba(0,0,0,0.25);
    font-family: "DotGothic16", "Press Start 2P", system-ui, sans-serif;
    overflow: hidden;
  }
  .profile.is-level-up {
    animation: ffLevelUp 0.38s steps(2, end);
  }
  @keyframes ffLevelUp {
    0%, 100% { filter: none; }
    50% { filter: brightness(1.35); }
  }
  .profile-character {
    display: grid;
    justify-items: center;
    gap: clamp(10px, 1.6vw, 18px);
    min-width: 0;
    align-self: start;
  }
  .profile-name,
  .profile-job,
  .profile-stats dt,
  .profile-stats dd {
    text-shadow: 3px 3px 0 #06155a;
  }
  .profile-name {
    font-size: clamp(19px, 2.4vw, 29px);
    line-height: 1;
    letter-spacing: 0.04em;
    color: #fff;
  }
  .avatar-btn {
    -webkit-appearance: none;
    appearance: none;
    font: inherit;
    display: block;
    width: 196px;
    height: 196px;
    border: none;
    border-radius: 0;
    background: transparent !important;
    box-shadow: none;
    color: inherit;
    padding: 0;
    margin: 0;
    cursor: pointer;
    line-height: 0;
    overflow: visible;
  }
  .avatar-btn:focus-visible {
    outline: 3px solid #46e2e3;
    outline-offset: 4px;
  }
  .profile .avatar {
    width: 196px;
    height: 196px;
    object-fit: contain;
    image-rendering: pixelated;
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 0;
    box-shadow: none;
  }
  .profile-info {
    display: grid;
    gap: clamp(14px, 2vw, 24px);
    min-width: 0;
    align-self: start;
  }
  .profile-job {
    font-size: clamp(19px, 2.4vw, 29px);
    line-height: 1;
    letter-spacing: 0.04em;
    color: #fff;
  }
  .profile-stats {
    display: grid;
    gap: clamp(8px, 1.3vw, 14px);
    margin: 0;
  }
  .profile-main-stat {
    display: grid;
    grid-template-columns: 2.05em 1fr;
    align-items: baseline;
    gap: clamp(34px, 7vw, 86px);
  }
  .profile-main-stat dt,
  .profile-main-stat dd {
    font-family: "Press Start 2P", "DotGothic16", system-ui, sans-serif;
    font-size: clamp(17px, 2.4vw, 27px);
    line-height: 1;
    letter-spacing: 0;
  }
  .profile-sub-stat {
    display: grid;
    grid-template-columns: 10em 0.5fr minmax(2.2ch, max-content);
    align-items: baseline;
    gap: 10px;
  }
  .profile-sub-stat dt,
  .profile-sub-stat .stat-dots {
    font-family: "DotGothic16", "Press Start 2P", system-ui, sans-serif;
    font-size: clamp(15px, 2vw, 22px);
    line-height: 1;
    letter-spacing: 0.02em;
  }
  .profile-sub-stat dd {
    font-family: "Press Start 2P", "DotGothic16", system-ui, sans-serif;
    font-size: clamp(15px, 2vw, 22px);
    line-height: 1;
    letter-spacing: 0.02em;
  }
  .profile-stats dt {
    color: #46e2e3;
  }
  .profile-sub-stat dt {
    font-weight: bold;
    white-space: nowrap;
  }
  .profile-stats dd {
    color: #fff;
    margin: 0;
  }
  .profile-sub-stat .stat-dots {
    color: #46e2e3;
    text-shadow: 3px 3px 0 #06155a;
    overflow: hidden;
    white-space: nowrap;
  }

  /* Likes list */
  .likes {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 28px;
  }
  .likes li {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 2px dotted rgba(26,18,8,0.25);
  }
  .likes .emoji {
    font-size: 1.4em;
    line-height: 1;
    flex: 0 0 auto;
  }
  .likes b {
    font-weight: normal;
    color: var(--line);
    letter-spacing: 0.04em;
  }
  .likes .desc {
    color: var(--ink-2);
    font-size: 0.92em;
  }

  .likes--text {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .likes--text li {
    display: grid;
    grid-template-columns: 8.5em 1fr;
    gap: 12px;
    align-items: start;
  }
  .likes--text b {
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: clamp(9px, 0.8vw, 11px);
    padding-top: 0.45em;
  }
  .likes--text .desc {
    line-height: 1.75;
  }
  .tip-trigger {
    position: relative;
    cursor: help;
    outline: none;
  }
  .tip-trigger::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 0;
    top: calc(100% + 8px);
    z-index: 30;
    width: max-content;
    max-width: min(330px, calc(100vw - 48px));
    padding: 8px 10px;
    background: #050806;
    border: 2px solid #fff;
    border-radius: 4px;
    box-shadow:
      0 0 0 2px #111,
      3px 3px 0 rgba(0,0,0,0.45);
    color: #fff;
    font-family: "DotGothic16", "Hiragino Maru Gothic ProN", system-ui, sans-serif;
    font-size: 13px;
    font-weight: normal;
    line-height: 1.55;
    letter-spacing: 0.02em;
    opacity: 0;
    pointer-events: none;
    text-shadow: 2px 2px 0 #000;
    transform: translateY(-4px);
    transition: opacity 0.12s ease, transform 0.12s ease;
    white-space: normal;
  }
  .tip-trigger:hover::after,
  .tip-trigger:focus-visible::after,
  .tip-trigger.is-tooltip-open::after {
    opacity: 1;
    transform: translateY(0);
  }
  .tip-trigger:focus-visible {
    color: #fff;
  }
  .card:not(.profile) .likes li {
    border-bottom-color: rgba(255,255,255,0.28);
  }
  .card:not(.profile) .likes b,
  .card:not(.profile) .persona dt {
    color: #d5a181;
    text-shadow: 2px 2px 0 #000;
  }
  .card:not(.profile) .likes .desc {
    color: #fff;
  }

  /* Persona dl */
  .persona {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 12px clamp(16px, 2vw, 28px);
    margin: 0;
  }
  .persona dt {
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: clamp(10px, 0.95vw, 13px);
    letter-spacing: 0.06em;
    color: var(--line);
    padding-top: 6px;
    white-space: nowrap;
  }
  .persona dd {
    margin: 0;
    color: var(--ink);
  }
  .badge {
    display: inline-block;
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: clamp(13px, 1.2vw, 16px);
    background: var(--line);
    color: var(--hi);
    padding: 6px 10px;
    border-radius: 4px;
    letter-spacing: 0.08em;
    margin-right: 6px;
    box-shadow: 3px 3px 0 rgba(0,0,0,0.20);
  }

  /* ── SNS (bottom-right) ────────────────────────── */
  .sns {
    position: fixed;
    bottom: clamp(25px, 3vw, 40px);
    right: clamp(25px, 3vw, 44px);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: clamp(14px, 1.6vw, 26px);
  }
  .sns a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-decoration: none;
    transition: transform 0.2s ease;
  }
  .sns a:hover { transform: translateY(-3px); }
  .sns svg {
    height: clamp(26px, 2.4vw, 38px);
    width: auto;
    fill: #fff;
    display: block;
    filter: drop-shadow(0 2px 0 rgba(0,0,0,0.18));
  }

  @media (max-width: 640px) {
    .page-head { grid-template-columns: 1fr; }
    .page-doodle { justify-self: end; }
    .profile {
      grid-template-columns: 1fr;
      text-align: center;
      gap: 18px;
    }
    .profile-stats {
      justify-content: center;
    }
    .profile-main-stat {
      grid-template-columns: 2.05em minmax(120px, 1fr);
      gap: 34px;
      text-align: left;
    }
    .profile-sub-stat {
      grid-template-columns: 10em 0.5fr minmax(2.2ch, max-content);
      text-align: left;
    }
    .likes { grid-template-columns: 1fr; }
    .likes--text li { grid-template-columns: 1fr; gap: 4px; }
    .persona { grid-template-columns: 1fr; gap: 6px; }
    .nav { font-size: 11px; gap: 8px; }
  }
