
    :root {
      --ui: #17130fe8;
      --line: #6a4f2e;
      --gold: #ffd166;
      --text: #fff9ec;
      --muted: #cabba5;
    }

    * {
      box-sizing: border-box
    }

    html,
    body {
      margin: 0;
      width: 100%;
      height: 100%;
      overflow: hidden;
      background: #111;
      font-family: "Segoe UI", Tahoma, Arial, sans-serif
    }

    #gameWrap {
      position: fixed;
      inset: 0;
      overflow: hidden;
      background: #b8d9ea
    }

    canvas {
      position: absolute;
      inset: 0;
      display: block;
      width: 100%;
      height: 100%;
      cursor: crosshair;
      touch-action: none;
    }

    /* Lottie จะวางเป็น object layer เหนือ canvas และเลื่อนตาม camera */
    #lottieLayer {
      position: absolute;
      inset: 0;
      pointer-events: none;
      transform-origin: 0 0;
    }

    .lottie-object {
      position: absolute;
      transform-origin: center bottom;
      will-change: transform;
      contain: layout paint style;
      filter: drop-shadow(0 7px 5px rgba(40, 30, 15, .16));
    }

    .hud {
      position: fixed;
      inset: 0;
      pointer-events: none;
      color: var(--text)
    }

    .card {
      background: rgba(23, 19, 15, .96);
      border: 1px solid var(--line);
      border-radius: 14px;
      box-shadow: 0 8px 18px #0004;
      backdrop-filter: none;
      -webkit-backdrop-filter: none
    }

    .top-left {
      position: absolute;
      left: 14px;
      top: 14px;
      padding: 11px 14px
    }

    .brand {
      font-weight: 900;
      color: var(--gold);
      font-size: 15px
    }

    .small {
      font-size: 11px;
      color: var(--muted);
      margin-top: 3px
    }

    .zone {
      position: absolute;
      top: 15px;
      left: 50%;
      transform: translateX(-50%);
      padding: 10px 18px;
      min-width: 280px;
      text-align: center;
      font-weight: 900
    }

    .right {
      position: absolute;
      right: 14px;
      top: 14px;
      width: 230px;
      padding: 12px
    }

    .profile {
      display: flex;
      gap: 10px;
      align-items: center;
      padding-bottom: 10px;
      border-bottom: 1px solid #ffffff16
    }

    .avatar {
      width: 48px;
      height: 48px;
      border-radius: 50%;
      background: #2b2219;
      border: 2px solid #d49e3e;
      display: grid;
      place-items: center;
      font-size: 28px
    }

    .name {
      font-weight: 900
    }

    .lvl {
      color: #ffd66b;
      font-size: 12px;
      margin-top: 3px
    }

    .map-title {
      font-size: 12px;
      font-weight: 800;
      margin: 10px 0 7px;
      color: #eadbc3
    }

    .minimap {
      height: 150px;
      background: #d6c79f;
      border-radius: 10px;
      position: relative;
      overflow: hidden;
      border: 1px solid #ffffff18
    }

    .mini-zone {
      position: absolute;
      border-radius: 5px;
      opacity: .9
    }

    .m1 {
      left: 6px;
      top: 8px;
      width: 66px;
      height: 52px;
      background: #b7d9ef
    }

    .m2 {
      right: 6px;
      top: 8px;
      width: 66px;
      height: 52px;
      background: #f1d09a
    }

    .m3 {
      left: 6px;
      bottom: 8px;
      width: 66px;
      height: 52px;
      background: #a9d88d
    }

    .m4 {
      right: 6px;
      bottom: 8px;
      width: 66px;
      height: 52px;
      background: #9dd9df
    }

    .mini-road-v {
      position: absolute;
      left: 104px;
      top: 0;
      width: 23px;
      height: 100%;
      background: #b67c59
    }

    .mini-road-h {
      position: absolute;
      left: 0;
      top: 64px;
      width: 100%;
      height: 22px;
      background: #b67c59
    }

    .mini-dot {
      position: absolute;
      width: 10px;
      height: 10px;
      background: #ff5252;
      border: 2px solid #fff;
      border-radius: 50%;
      transform: translate(-50%, -50%);
      z-index: 5
    }

    .bottom {
      position: absolute;
      left: 50%;
      bottom: 14px;
      transform: translateX(-50%);
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 9px 12px
    }

    .key {
      display: grid;
      place-items: center;
      min-width: 32px;
      height: 32px;
      padding: 0 8px;
      border-radius: 8px;
      background: #2d241b;
      border: 1px solid #83643b;
      font-weight: 900
    }

    .tip {
      position: absolute;
      left: 14px;
      bottom: 14px;
      padding: 10px 12px;
      line-height: 1.55;
      font-size: 11px
    }

    .mobile {
      display: none
    }

    @media(max-width:800px) {
      .right {
        width: 170px
      }

      .bottom,
      .tip {
        display: none
      }

      .mobile {
        display: block;
        position: absolute;
        left: 14px;
        bottom: 16px;
        width: 146px;
        height: 146px;
        pointer-events: auto
      }

      .mobile button {
        position: absolute;
        width: 48px;
        height: 48px;
        border-radius: 12px;
        border: 1px solid #7a5a34;
        background: #17130fdd;
        color: #fff;
        font-size: 20px
      }

      .mobile .u {
        left: 49px;
        top: 0
      }

      .mobile .d {
        left: 49px;
        bottom: 0
      }

      .mobile .l {
        left: 0;
        top: 49px
      }

      .mobile .r {
        right: 0;
        top: 49px
      }
    }

    /* ==========================================================
   CHARACTER SELECTOR — เพิ่มใหม่โดยไม่กระทบระบบเดิม
   ========================================================== */
    .avatar {
      overflow: hidden;
    }

    .avatar img {
      width: 100%;
      height: 100%;
      object-fit: contain;
      image-rendering: auto;
    }

    #characterSetup {
      position: fixed;
      inset: 0;
      z-index: 9999;
      display: grid;
      place-items: center;
      padding: 24px;
      background: rgba(19, 16, 25, .76);
      backdrop-filter: blur(10px);
      color: #fff9ec;
    }

    #characterSetup.hidden {
      display: none;
    }

    .character-panel {
      width: min(940px, 94vw);
      max-height: 92vh;
      overflow: auto;
      padding: 24px;
      border: 1px solid #745838;
      border-radius: 24px;
      background:
        radial-gradient(circle at 50% 0%, rgba(84, 120, 255, .18), transparent 42%),
        linear-gradient(180deg, #211a2cf5, #151117f7);
      box-shadow: 0 28px 90px #000b;
    }

    .character-title {
      text-align: center;
      font-size: 28px;
      font-weight: 1000;
      color: #ffd166;
      margin-bottom: 5px;
    }

    .character-subtitle {
      text-align: center;
      color: #cfc3d7;
      font-size: 13px;
      margin-bottom: 20px;
    }

    .character-grid {
      display: grid;
      grid-template-columns: repeat(5, minmax(110px, 1fr));
      gap: 12px;
    }

    .character-choice {
      position: relative;
      min-height: 150px;
      padding: 10px 8px 9px;
      border: 2px solid #4f435b;
      border-radius: 18px;
      background: #282031;
      color: #fff;
      cursor: pointer;
      transition: .16s ease;
    }

    .character-choice:hover {
      transform: translateY(-3px);
      border-color: #9878cb;
      background: #30253d;
    }

    .character-choice.selected {
      border-color: #ffd166;
      background: #3a2d43;
      box-shadow: 0 0 0 3px rgba(255, 209, 102, .12), 0 0 24px rgba(89, 167, 255, .16);
    }

    .character-choice img {
      display: block;
      width: 92px;
      height: 92px;
      margin: 0 auto 5px;
      object-fit: contain;
      filter: drop-shadow(0 8px 5px rgba(0, 0, 0, .28));
    }

    .character-choice .cat-label {
      font-weight: 900;
      font-size: 12px;
    }

    .character-choice .check {
      position: absolute;
      right: 8px;
      top: 8px;
      display: none;
      width: 23px;
      height: 23px;
      border-radius: 50%;
      place-items: center;
      background: #ffd166;
      color: #36250f;
      font-weight: 1000;
    }

    .character-choice.selected .check {
      display: grid;
    }

    .character-form {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 10px;
      margin-top: 18px;
    }

    #characterNameInput {
      min-width: 0;
      height: 48px;
      padding: 0 16px;
      border-radius: 14px;
      border: 1px solid #695779;
      outline: none;
      background: #151119;
      color: white;
      font-size: 16px;
      font-weight: 800;
    }

    #characterNameInput:focus {
      border-color: #ffd166;
      box-shadow: 0 0 0 3px rgba(255, 209, 102, .10);
    }

    #startGameBtn {
      height: 48px;
      padding: 0 24px;
      border: 0;
      border-radius: 14px;
      cursor: pointer;
      font-weight: 1000;
      color: #34240e;
      background: linear-gradient(#ffe18a, #ffc94f);
      box-shadow: 0 7px 0 #a87322;
    }

    #startGameBtn:active {
      transform: translateY(3px);
      box-shadow: 0 4px 0 #a87322;
    }

    #characterError {
      min-height: 20px;
      margin-top: 8px;
      color: #ff9999;
      font-size: 12px;
      text-align: center;
      font-weight: 800;
    }

    .change-character-btn {
      pointer-events: auto;
      margin-top: 8px;
      width: 100%;
      border: 1px solid #70573a;
      border-radius: 8px;
      background: #2d241b;
      color: #ffe8b3;
      padding: 6px 8px;
      cursor: pointer;
      font-size: 11px;
      font-weight: 900;
    }

    .change-character-btn:hover {
      background: #3a2d20;
    }

    @media(max-width:720px) {
      .character-grid {
        grid-template-columns: repeat(2, 1fr)
      }

      .character-panel {
        padding: 17px
      }

      .character-form {
        grid-template-columns: 1fr
      }

      .character-choice {
        min-height: 135px
      }
    }


    /* ==========================================================
   CHAT / SPEECH BUBBLE UI
   ========================================================== */
    .chat-composer {
      position: absolute;
      left: 50%;
      bottom: 72px;
      transform: translateX(-50%);
      z-index: 80;
      display: flex;
      align-items: center;
      gap: 7px;
      width: min(680px, calc(100vw - 32px));
      padding: 8px;
      pointer-events: auto;
    }

    .chat-composer input {
      flex: 1;
      min-width: 0;
      height: 38px;
      padding: 0 12px;
      border: 1px solid #71583a;
      border-radius: 10px;
      outline: none;
      background: #17130ff2;
      color: #fff;
      font: 700 13px "Segoe UI", Tahoma, Arial, sans-serif;
    }

    .chat-composer input:focus {
      border-color: #ffd166;
      box-shadow: 0 0 0 3px rgba(255, 209, 102, .12);
    }

    .chat-composer select {
      height: 38px;
      min-width: 118px;
      padding: 0 8px;
      border: 1px solid #71583a;
      border-radius: 10px;
      outline: none;
      background: #2b2219;
      color: #fff4d3;
      font: 800 12px "Segoe UI", Tahoma, Arial, sans-serif;
      cursor: pointer;
    }

    .chat-composer button {
      height: 38px;
      padding: 0 14px;
      border: 1px solid #9a6d25;
      border-radius: 10px;
      background: linear-gradient(#ffe18a, #ffc94f);
      color: #33230d;
      font-weight: 1000;
      cursor: pointer;
      box-shadow: 0 4px 0 #8b5f1c;
    }

    .chat-composer button:active {
      transform: translateY(2px);
      box-shadow: 0 2px 0 #8b5f1c;
    }

    .chat-effect-label {
      color: #cdbfa9;
      font-size: 10px;
      white-space: nowrap;
    }

    @media(max-width:800px) {
      .chat-composer {
        bottom: 172px;
        flex-wrap: wrap;
      }

      .chat-composer input {
        flex-basis: 100%;
      }

      .chat-composer select {
        flex: 1;
      }
    }


    /* ==========================================================
   EMOTION LOTTIE — อีโมจิค้างบนหัว
   ========================================================== */
    #emotionLayer {
      position: absolute;
      inset: 0;
      pointer-events: none;
      z-index: 60;
    }

    #playerEmotion {
      position: absolute;
      width: 72px;
      height: 72px;
      will-change: left, top;
      transform: translate(-50%, -100%);
      pointer-events: none;
      filter: drop-shadow(0 5px 5px rgba(0, 0, 0, .22));
    }

    .emotion-controls {
      position: absolute;
      left: 14px;
      top: 132px;
      width: 205px;
      padding: 10px;
      pointer-events: auto;
      z-index: 90;
    }

    .emotion-controls .emotion-title {
      font-weight: 1000;
      color: #ffd166;
      font-size: 12px;
      margin-bottom: 7px;
    }

    .emotion-controls select {
      width: 100%;
      height: 34px;
      border: 1px solid #72583a;
      border-radius: 9px;
      background: #2a2119;
      color: #fff4d3;
      padding: 0 8px;
      outline: none;
      font-weight: 800;
    }

    .emotion-actions {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 7px;
      margin-top: 7px;
    }

    .emotion-actions button {
      min-height: 34px;
      border: 1px solid #846235;
      border-radius: 9px;
      cursor: pointer;
      font-size: 11px;
      font-weight: 1000;
      color: #fff;
      background: #34291f;
    }

    .emotion-actions button:first-child {
      color: #38250b;
      background: linear-gradient(#ffe18a, #ffc94f);
    }

    .emotion-actions button:last-child {
      background: #3b2024;
      border-color: #764249;
    }

    @media(max-width:800px) {
      .emotion-controls {
        top: auto;
        left: auto;
        right: 14px;
        bottom: 172px;
        width: 170px;
      }
    }


    /* ==========================================================
   CHARACTER SELECT — visible scrollbar / more-characters hint
   ========================================================== */
    .character-panel {
      overflow: hidden !important;
      display: flex;
      flex-direction: column;
      max-height: 92vh;
    }

    .character-grid {
      overflow-y: scroll;
      overflow-x: hidden;
      max-height: min(520px, 58vh);
      padding: 4px 12px 22px 4px;
      scrollbar-gutter: stable;
      overscroll-behavior: contain;
    }

    /* Chromium / Safari */
    .character-grid::-webkit-scrollbar {
      width: 13px;
    }

    .character-grid::-webkit-scrollbar-track {
      background: #17121d;
      border-radius: 999px;
      border: 1px solid #493b51;
    }

    .character-grid::-webkit-scrollbar-thumb {
      background: linear-gradient(#ffd166, #b98b45);
      border-radius: 999px;
      border: 3px solid #17121d;
    }

    .character-grid::-webkit-scrollbar-thumb:hover {
      background: linear-gradient(#ffe49a, #d5a758);
    }

    /* Firefox */
    .character-grid {
      scrollbar-width: auto;
      scrollbar-color: #d7a64e #17121d;
    }

    .character-scroll-hint {
      position: relative;
      text-align: center;
      margin: -3px 0 8px;
      padding: 7px 10px;
      color: #ffd98a;
      font-size: 12px;
      font-weight: 900;
      flex: 0 0 auto;
    }

    .character-scroll-hint .scroll-arrow {
      display: inline-block;
      margin-left: 5px;
      animation: characterScrollHint 1.1s ease-in-out infinite;
    }

    @keyframes characterScrollHint {

      0%,
      100% {
        transform: translateY(-2px)
      }

      50% {
        transform: translateY(3px)
      }
    }

    @media(max-width:720px) {
      .character-grid {
        max-height: 52vh;
      }
    }


    /* ===== CHARACTER SCROLLBAR: บังคับให้เห็นค้างไว้ ===== */
    .character-grid {
      overflow-y: scroll !important;
      scrollbar-gutter: stable !important;
    }

    /* Chrome / Edge / Safari */
    .character-grid::-webkit-scrollbar {
      width: 16px !important;
      -webkit-appearance: none;
    }

    .character-grid::-webkit-scrollbar-track {
      background: #151019 !important;
      border: 2px solid #5b4963 !important;
      border-radius: 999px;
      box-shadow: inset 0 0 4px rgba(0, 0, 0, .55);
    }

    .character-grid::-webkit-scrollbar-thumb {
      min-height: 55px;
      background: #ffd166 !important;
      border: 3px solid #151019 !important;
      border-radius: 999px;
      box-shadow: 0 0 0 1px #a8792c;
    }

    .character-grid::-webkit-scrollbar-thumb:hover {
      background: #ffe29a !important;
    }

    /* Firefox */
    .character-grid {
      scrollbar-width: auto !important;
      scrollbar-color: #ffd166 #151019 !important;
    }


    /* ===== PET SHOP AFFILIATE MODAL ===== */
    .shop-modal {
      position: fixed;
      inset: 0;
      z-index: 10050;
      display: grid;
      place-items: center;
      padding: 20px;
      background: rgba(8, 6, 10, .62);
      pointer-events: auto
    }

    .shop-modal.hidden {
      display: none
    }

    .shop-modal-card {
      width: min(520px, 94vw);
      padding: 20px;
      border: 1px solid #8d6734;
      border-radius: 20px;
      background: #1d1713;
      color: #fff9ec;
      box-shadow: 0 24px 80px #000b
    }

    .shop-modal-title {
      font-size: 22px;
      font-weight: 1000;
      color: #ffd166;
      margin-bottom: 6px
    }

    .shop-modal-sub {
      font-size: 12px;
      color: #cabba5;
      margin-bottom: 14px
    }

    .affiliate-links {
      display: grid;
      gap: 9px
    }

    .affiliate-link {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 12px 14px;
      border: 1px solid #7c5930;
      border-radius: 12px;
      background: #2c2118;
      color: #fff;
      text-decoration: none;
      font-weight: 900
    }

    .affiliate-link:hover {
      background: #3a2b1e;
      border-color: #ffd166
    }

    .affiliate-link span:last-child {
      color: #ffd166
    }

    .shop-modal-close {
      width: 100%;
      margin-top: 15px;
      height: 42px;
      border: 0;
      border-radius: 11px;
      cursor: pointer;
      font-weight: 1000;
      background: linear-gradient(#ffe18a, #ffc94f);
      color: #33230d
    }


    .affiliate-product-img {
      width: 50px;
      height: 50px;
      min-width: 50px;
      object-fit: cover;
      border-radius: 10px;
      display: block;
    }

    .affiliate-product-name {
      flex: 1;
      text-align: left;
    }

    /* ===== SHOP QUICK VIEW ICONS ===== */
    #shopIconLayer{
      position:absolute;
      inset:0;
      pointer-events:none;
      z-index:72;
      transform:translate3d(0,0,0);
      will-change:transform;
      backface-visibility:hidden;
      contain:layout style;
    }

    .shop-view-icon{
      position:absolute;
      width:38px;
      height:38px;
      border:2px solid #ffd166;
      border-radius:50%;
      display:grid;
      place-items:center;
      padding:0;
      background:rgba(31,24,18,.94);
      color:#fff;
      font-size:18px;
      cursor:pointer;
      pointer-events:auto;
      box-shadow:0 5px 14px rgba(0,0,0,.35),0 0 0 3px rgba(255,209,102,.10);
      transform:translate(-50%,-50%);
      transition:transform .14s ease,background .14s ease,border-color .14s ease;
      will-change:transform;
      backface-visibility:hidden;
    }

    .shop-view-icon:hover{
      transform:translate(-50%,-50%) scale(1.10);
      background:#4a3622;
      border-color:#ffe69f;
    }

    .shop-view-icon:active{
      transform:translate(-50%,-50%) scale(.96);
    }

    .shop-view-icon.hidden{
      visibility:hidden;
      pointer-events:none;
    }

    @media(max-width:800px){
      .shop-view-icon{
        width:34px;
        height:34px;
        font-size:16px;
      }
    }


    /* ===== COLLAPSIBLE MINI MAP ===== */
    .map-title-row{
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:8px;
      margin:10px 0 7px;
    }

    .map-title-row .map-title{
      margin:0;
    }

    .map-toggle-btn{
      pointer-events:auto;
      border:1px solid #70573a;
      border-radius:8px;
      background:#2d241b;
      color:#ffe8b3;
      min-width:58px;
      height:28px;
      padding:0 8px;
      cursor:pointer;
      font-size:11px;
      font-weight:900;
    }

    .map-toggle-btn:hover{
      background:#3a2d20;
    }

    #mapPanelContent{
      overflow:hidden;
      max-height:260px;
      opacity:1;
      transition:max-height .22s ease,opacity .18s ease;
    }

    #mapPanelContent.collapsed{
      max-height:0;
      opacity:0;
      pointer-events:none;
    }

    /* ใช้กับ icon แว่นขยายทั้งร้านค้าและอาคารพิเศษ */
    .shop-view-icon.location-special{
      border-color:#8ee7ff;
      box-shadow:0 5px 14px rgba(0,0,0,.35),0 0 0 3px rgba(100,220,255,.10);
    }


    /* ==========================================================
       FISHING SYSTEM UI
       ========================================================== */
    .fishing-panel{
      position:absolute;
      left:14px;
      bottom:92px;
      z-index:95;
      width:210px;
      padding:11px;
      pointer-events:auto;
    }

    .fishing-title{
      color:#7ee8ff;
      font-size:13px;
      font-weight:1000;
      margin-bottom:6px;
    }

    .fishing-status{
      min-height:34px;
      color:#e8f9ff;
      font-size:11px;
      line-height:1.45;
    }

    .fishing-progress{
      height:8px;
      margin:8px 0;
      overflow:hidden;
      border-radius:99px;
      border:1px solid #5a6f75;
      background:#10191c;
    }

    .fishing-progress > div{
      width:0%;
      height:100%;
      background:linear-gradient(90deg,#65d7ff,#ffd166);
      transition:width .15s linear;
    }

    .fishing-actions-row{
      display:grid;
      grid-template-columns:1fr 1fr;
      gap:7px;
    }

    .fishing-button{
      width:100%;
      height:38px;
      border:1px solid #88703d;
      border-radius:10px;
      cursor:pointer;
      font-weight:1000;
      color:#2a220f;
      background:linear-gradient(#bff5ff,#6fd4f1);
      box-shadow:0 4px 0 #397f91;
    }

    .fishing-cancel-button{
      width:100%;
      height:38px;
      border:1px solid #7b4747;
      border-radius:10px;
      cursor:pointer;
      font-weight:1000;
      color:#fff3f3;
      background:#53292d;
      box-shadow:0 4px 0 #35191c;
    }

    .fishing-cancel-button:hover{
      background:#683238;
    }

    .fishing-cancel-button:active{
      transform:translateY(2px);
      box-shadow:0 2px 0 #35191c;
    }

    .fishing-cancel-button:disabled{
      cursor:not-allowed;
      opacity:.42;
      transform:none;
      box-shadow:none;
    }

    .fishing-button:active{
      transform:translateY(2px);
      box-shadow:0 2px 0 #397f91;
    }

    .fishing-button:disabled{
      cursor:not-allowed;
      opacity:.52;
      transform:none;
      box-shadow:none;
    }

    .fishing-space-count{
      margin-top:7px;
      color:#ffd166;
      font-size:12px;
      font-weight:1000;
      text-align:center;
    }

    .fish-result-modal{
      position:fixed;
      inset:0;
      z-index:10150;
      display:grid;
      place-items:center;
      padding:20px;
      background:rgba(5,10,15,.72);
      pointer-events:auto;
    }

    .fish-result-modal.hidden{display:none}

    .fish-result-card{
      width:min(420px,92vw);
      padding:22px;
      border:1px solid #4da7bb;
      border-radius:22px;
      text-align:center;
      background:linear-gradient(180deg,#16262d,#10191e);
      color:#fff;
      box-shadow:0 26px 90px #000c;
    }

    .fish-result-title{
      color:#7ee8ff;
      font-size:24px;
      font-weight:1000;
      margin-bottom:4px;
    }

    .fish-result-img{
      width:180px;
      height:180px;
      object-fit:contain;
      display:block;
      margin:8px auto;
      filter:drop-shadow(0 12px 9px rgba(0,0,0,.35));
    }

    .fish-result-level{
      color:#ffd166;
      font-size:22px;
      font-weight:1000;
      margin:6px 0;
    }

    .fish-result-detail{
      color:#d7e9ee;
      font-size:12px;
      line-height:1.6;
    }

    .fish-result-actions{
      display:grid;
      grid-template-columns:1fr 1fr;
      gap:8px;
      margin-top:15px;
    }

    .fish-result-actions button{
      height:40px;
      border:0;
      border-radius:10px;
      cursor:pointer;
      font-weight:1000;
    }

    .fish-result-actions button:first-child{
      background:linear-gradient(#bff5ff,#6fd4f1);
      color:#15313a;
    }

    .fish-result-actions button:last-child{
      background:#2b3438;
      color:#fff;
      border:1px solid #52646c;
    }

    @media(max-width:800px){
      .fishing-panel{
        left:auto;
        right:14px;
        bottom:332px;
        width:180px;
      }
    }


    /* ===== COLLAPSIBLE EMOTION PANEL ===== */
    .emotion-title-row{
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:8px;
      margin-bottom:7px;
    }

    .emotion-title-row .emotion-title{
      margin-bottom:0;
    }

    .emotion-toggle-btn{
      pointer-events:auto;
      min-width:54px;
      height:27px;
      padding:0 8px;
      border:1px solid #72583a;
      border-radius:8px;
      cursor:pointer;
      background:#2d241b;
      color:#ffe8b3;
      font-size:10px;
      font-weight:1000;
    }

    .emotion-toggle-btn:hover{
      background:#3a2d20;
    }

    #emotionPanelContent{
      overflow:hidden;
      max-height:160px;
      opacity:1;
      transition:max-height .22s ease,opacity .18s ease,margin .18s ease;
    }

    #emotionPanelContent.collapsed{
      max-height:0;
      opacity:0;
      margin:0;
      pointer-events:none;
    }


    /* ==========================================================
       GUILD CHAT — ห้องแชทกลางของกิลด์แมว / กิลด์หมา
       แยกจากแชทเหนือหัวเดิม เพื่อไม่กระทบระบบเดิม
       ========================================================== */
    .guild-chat-modal{
      position:fixed;
      inset:0;
      z-index:10250;
      display:grid;
      place-items:center;
      padding:20px;
      background:rgba(7,6,10,.70);
      pointer-events:auto;
    }

    .guild-chat-modal.hidden{display:none}

    .guild-chat-card{
      width:min(720px,94vw);
      height:min(680px,88vh);
      display:flex;
      flex-direction:column;
      overflow:hidden;
      border:1px solid #8d6734;
      border-radius:22px;
      background:
        radial-gradient(circle at 50% 0%,rgba(255,209,102,.10),transparent 36%),
        #1b1613;
      color:#fff9ec;
      box-shadow:0 28px 95px #000c;
    }

    .guild-chat-header{
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:12px;
      padding:15px 16px;
      border-bottom:1px solid #ffffff14;
      background:#241c16;
    }

    .guild-chat-heading{
      min-width:0;
    }

    .guild-chat-title{
      color:#ffd166;
      font-size:20px;
      font-weight:1000;
      line-height:1.2;
    }

    .guild-chat-subtitle{
      margin-top:4px;
      color:#cabba5;
      font-size:11px;
    }

    .guild-chat-close{
      width:38px;
      height:38px;
      flex:0 0 38px;
      border:1px solid #73543a;
      border-radius:11px;
      background:#33251d;
      color:#fff4df;
      cursor:pointer;
      font-size:20px;
      font-weight:900;
    }

    .guild-chat-close:hover{
      background:#493226;
      border-color:#ffd166;
    }

    .guild-chat-messages{
      flex:1;
      min-height:0;
      overflow-y:auto;
      padding:16px;
      scroll-behavior:smooth;
    }

    .guild-chat-empty{
      margin:26px auto;
      max-width:390px;
      padding:16px;
      border:1px dashed #66513b;
      border-radius:14px;
      color:#bdae99;
      text-align:center;
      font-size:12px;
      line-height:1.6;
    }

    .guild-message{
      display:flex;
      align-items:flex-start;
      gap:10px;
      margin-bottom:14px;
    }

    .guild-message.own{
      /* ข้อความของเราเรียงซ้ายเหมือนสมาชิกคนอื่น เพื่ออ่านต่อเนื่องง่ายขึ้น */
      flex-direction:row;
    }

    .guild-message-avatar{
      width:42px;
      height:42px;
      flex:0 0 42px;
      overflow:hidden;
      border:2px solid #a57a3a;
      border-radius:50%;
      background:#2b2219;
    }

    .guild-message-avatar img{
      width:100%;
      height:100%;
      display:block;
      object-fit:contain;
    }

    .guild-message-body{
      max-width:min(78%,520px);
    }

    .guild-message-meta{
      display:flex;
      align-items:center;
      gap:7px;
      margin-bottom:4px;
      color:#c7b9a5;
      font-size:10px;
    }

    .guild-message.own .guild-message-meta{
      justify-content:flex-start;
    }

    .guild-message-name{
      color:#ffe19a;
      font-size:12px;
      font-weight:1000;
    }

    .guild-message-bubble{
      padding:10px 12px;
      border:1px solid #65503c;
      border-radius:6px 14px 14px 14px;
      background:#2a211b;
      color:#fffaf1;
      font-size:13px;
      line-height:1.5;
      white-space:pre-wrap;
      overflow-wrap:anywhere;
    }

    .guild-message.own .guild-message-bubble{
      border-color:#9b762f;
      border-radius:6px 14px 14px 14px;
      background:#4b391c;
    }

    .guild-chat-composer{
      display:grid;
      grid-template-columns:1fr auto;
      gap:8px;
      padding:12px;
      border-top:1px solid #ffffff14;
      background:#211914;
    }

    #guildChatInput{
      min-width:0;
      height:44px;
      padding:0 13px;
      border:1px solid #6e553b;
      border-radius:11px;
      outline:none;
      background:#120f0d;
      color:#fff;
      font:700 13px "Segoe UI",Tahoma,Arial,sans-serif;
    }

    #guildChatInput:focus{
      border-color:#ffd166;
      box-shadow:0 0 0 3px rgba(255,209,102,.10);
    }

    #guildChatSendBtn{
      min-width:88px;
      height:44px;
      padding:0 16px;
      border:0;
      border-radius:11px;
      cursor:pointer;
      background:linear-gradient(#ffe18a,#ffc94f);
      color:#33230d;
      font-weight:1000;
      box-shadow:0 4px 0 #8b5f1c;
    }

    #guildChatSendBtn:active{
      transform:translateY(2px);
      box-shadow:0 2px 0 #8b5f1c;
    }

    .guild-room-link{
      width:100%;
      border:0;
      cursor:pointer;
      font:inherit;
    }

    @media(max-width:640px){
      .guild-chat-card{
        height:min(720px,92vh);
      }

      .guild-message-body{
        max-width:82%;
      }

      .guild-chat-composer{
        grid-template-columns:1fr;
      }

      #guildChatSendBtn{
        width:100%;
      }
    }

  
/* The only visible world canvas is owned by Pixi/WebGL. */
#lottieLayer, #emotionLayer { display: none; }
.startup-error {
  position: fixed; inset: 20px 20px auto; z-index: 20000;
  padding: 18px; border: 1px solid #ffb8a5; border-radius: 12px;
  background: #401e1e; color: #fff; text-align: center;
}

.sound-toggle-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 8px 12px;
  border: 1px solid #6e553b;
  border-radius: 10px;
  background: #30251c;
  color: #fff;
  font: 700 12px "Segoe UI", Tahoma, sans-serif;
  cursor: pointer;
  pointer-events: auto;
}
.sound-toggle-btn:hover { background: #453425; }
.sound-toggle-btn:focus-visible { outline: 2px solid #ffd166; outline-offset: 2px; }
.sound-toggle-btn[aria-pressed="true"] { color: #ffd166; }

/* Library cards and the article reader are scoped to the library only. */
#libraryModal .shop-modal-card {
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  box-sizing: border-box;
}
.library-article-link { width: 100%; font: inherit; text-align: left; cursor: pointer; }
#libraryArticleDialog {
  width: min(620px, calc(100vw - 28px));
  max-width: none;
  max-height: 88vh;
  max-height: 88dvh;
  padding: 0;
  border: 1px solid #8d6734;
  border-radius: 20px;
  background: #1d1713;
  color: #fff9ec;
  box-shadow: 0 24px 80px #000b;
  overflow: hidden;
  pointer-events: auto;
}
#libraryArticleDialog[open] { display: flex; flex-direction: column; }
#libraryArticleDialog::backdrop { background: rgb(8 6 10 / 78%); }
.library-article-header { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid #61472e; flex-shrink: 0; }
.library-article-header h2 { flex: 1; margin: 0; color: #ffd166; font-size: 20px; }
#closeLibraryArticle { width: 40px; height: 40px; flex-shrink: 0; border: 1px solid #8d6734; border-radius: 10px; color: #fff; background: #392b20; font-size: 26px; cursor: pointer; }
.library-article-body { min-height: 0; padding: 18px 22px; overflow-y: auto; overscroll-behavior: contain; line-height: 1.85; font-size: 15px; }
.library-article-body img { display: block; width: 100%; height: auto; border-radius: 14px; }
.library-article-body h3 { margin: 22px 0 6px; color: #ffe2a2; font-size: 17px; }
.library-article-body p { margin: 8px 0 16px; }
.library-article-sources { font-size: 12px; color: #cabba5; }
.library-article-sources a { display: inline-block; color: #a8d9ff; margin-right: 10px; }
.library-article-footer { padding: 12px 20px 18px; border-top: 1px solid #61472e; flex-shrink: 0; }
.library-article-footer button { width: 100%; }
#libraryArticleDialog button:focus-visible, .library-article-link:focus-visible { outline: 2px solid #ffd166; outline-offset: 2px; }

/* Review board uses the same dark wood and gold palette as the game shops. */
#foodReviewsModal { background: rgba(8, 6, 10, .68); }
#foodReviewsModal .food-reviews-card { width: min(680px, 94vw); max-height: 90vh; max-height: 90dvh; display: flex; flex-direction: column; box-sizing: border-box; padding: 0; border: 1px solid #8d6734; border-radius: 22px; background: #1d1713; color: #fff9ec; box-shadow: 0 24px 80px #000b, inset 0 0 0 3px #352719; }
.food-reviews-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 24px 26px 16px; border-bottom: 1px solid #61472e; flex-shrink: 0; }
.food-reviews-header h2 { font-size: 23px; line-height: 1.4; margin: 3px 0; font-weight: 900; color: #ffd166; }
.food-eyebrow { font-size: 11px; color: #e4b967; letter-spacing: .07em; }
.food-subtitle { font-size: 13px; color: #cabba5; margin: 6px 0 0; }
.food-reviews-scroll { overflow-y: auto; min-height: 0; overscroll-behavior: contain; padding: 0 26px 24px; }
#foodReviewsModal textarea { box-sizing: border-box; width: 100%; resize: vertical; max-height: 200px; padding: 13px; background: #120f0d; color: #fff9ec; border: 1px solid #7c5930; border-radius: 12px; font: inherit; font-size: 16px; line-height: 1.7; }
#foodReviewsModal textarea::placeholder { color: #ac9b88; }
#foodReviewsModal textarea[aria-invalid="true"] { border-color: #ff9b8b; }
#foodReviewsModal label { display: block; margin: 14px 0 8px; font-size: 13px; font-weight: 600; }
#foodReviewsModal button { cursor: pointer; border: 1px solid #7c5930; border-radius: 10px; padding: 10px 14px; background: #2c2118; color: #ffe2a2; font: inherit; font-size: 14px; min-height: 42px; }
#foodReviewsModal button:hover { background: #3a2b1e; }
#foodReviewsModal button:disabled { opacity: .5; cursor: wait; }
#foodReviewsModal :is(button, textarea, input, summary):focus-visible { outline: 2px solid #ffd166; outline-offset: 3px; }
#foodReviewsModal #closeFoodReviews { padding: 4px; min-width: 40px; font-size: 24px; border: 1px solid #8d6734; background: #392b20; flex-shrink: 0; }
#foodReviewsStatus { color: #ffd166; font-size: 13px; padding: 0 26px; flex-shrink: 0; }
#foodReviewsStatus:empty { margin: 8px 0; }
#foodComposer { border: 1px solid #8d6734; border-radius: 14px; background: #2c2118; padding: 0 16px; }
#foodComposerToggle { cursor: pointer; padding: 15px 0; color: #ffd166; font-weight: 800; list-style: none; }
#foodComposerToggle::-webkit-details-marker { display: none; }
#foodComposerToggle span { display: block; font-size: 12px; font-weight: 400; margin: 4px 0 0 20px; color: #cabba5; }
.food-input-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; color: #cabba5; margin-top: 6px; }
.food-field-error { color: #ffad9e; font-size: 12px; margin: 6px 0; }
.food-field-error:empty { display: none; }
#foodThreadImage { max-width: 100%; margin-bottom: 12px; font-size: 12px; }
#foodThreadImage::file-selector-button { padding: 9px 12px; margin-right: 10px; border: 1px solid #8d6734; border-radius: 8px; background: #2c2118; color: #ffe2a2; cursor: pointer; }
#foodReviewsModal :is(#foodThreadSubmit, #foodReplySubmit) { display: block; margin: 16px 0; background: linear-gradient(#ffe18a, #ffc94f); color: #33230d; border-color: #e4b254; font-weight: 900; box-shadow: 0 3px 0 #8b5f1c; }
#foodReviewsModal :is(#foodThreadSubmit, #foodReplySubmit):hover { background: linear-gradient(#ffebb0, #ffd568); }
.food-section-title, #foodThreadDetail h3 { margin: 22px 0 12px; font-size: 15px; font-weight: 800; }
#foodReviewsModal .food-thread { display: block; width: 100%; text-align: left; margin: 9px 0; padding: 17px; border-radius: 14px; }
.food-thread strong, .food-thread small { display: block; white-space: pre-wrap; overflow-wrap: anywhere; }
.food-thread strong { font-weight: 550; color: #fff9ec; line-height: 1.7; }
.food-thread small, .food-reply small, #foodThreadContent small { color: #cabba5; font-size: 11px; margin-top: 10px; }
.food-reply { background: #2c2118; border: 1px solid #61472e; border-radius: 12px; padding: 12px 16px; margin: 10px 0; }
.food-reply p, #foodThreadContent p { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; }
.food-post-image, #foodImagePreview { max-width: 100%; max-height: 300px; object-fit: contain; border-radius: 12px; }
#foodThreadContent { margin: 16px 0; border-bottom: 1px solid #61472e; padding-bottom: 16px; }
#foodReplyForm { border-top: 1px solid #61472e; margin-top: 20px; }
@media (max-width: 480px) {
  .food-reviews-header { padding: 18px 16px 14px; }
  .food-reviews-header h2 { font-size: 20px; }
  .food-reviews-scroll { padding: 0 16px 20px; }
  #foodReviewsStatus { padding: 0 16px; }
  #foodReviewsModal :is(#foodThreadSubmit, #foodReplySubmit) { width: 100%; }
}

#foodReviewsModal .food-reviews-header { background: linear-gradient(#35271b, #241b14); border-radius: 21px 21px 0 0; }
#foodReviewsModal .food-reviews-scroll { scrollbar-width: thin; scrollbar-color: #8d6734 #1d1713; }
#foodReviewsModal .food-section-title { color: #ffd166; }
#foodReviewsModal .food-thread:hover { border-color: #ffd166; }
#foodReviewsModal :is(#foodThreadSubmit, #foodReplySubmit):active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #8b5f1c; }

/* Keep fishing controls hidden outside fishing range, including first paint. */
#fishingPanel[hidden] { display: none; }
