/* ================= CĂNG-TIN (MARKET) & HỆ THỐNG XÃ HỘI ================= */
.market-hud {
    position: fixed; z-index: 18; display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px;
    color: #293951; background: #fff5dd; border: 2px solid #876244; border-radius: 14px;
    box-shadow: 0 3px 0 #79523845; font: 700 14px Tahoma, sans-serif;
}
#market-wallet {
    right: max(64px, calc(env(safe-area-inset-right) + 60px)); top: max(14px, env(safe-area-inset-top));
    pointer-events: none; flex-wrap: wrap; gap: 3px 6px; justify-content: center; max-width: 153px;
}
#market-bag { bottom: max(16px, env(safe-area-inset-bottom)); left: max(14px, env(safe-area-inset-left)); cursor: pointer; min-height: 42px; }
#market-bag strong { background: #2a3956; color: #fff7e6; border-radius: 12px; padding: 2px 8px; }
#social-clock { flex-basis: 100%; font: 11px Tahoma, sans-serif; text-align: center; color: #66533b; font-variant-numeric: tabular-nums; }
#social-hub { left: 14px; bottom: max(69px, calc(env(safe-area-inset-bottom) + 53px)); min-height: 42px; cursor: pointer; color: #803953; }
.market-hud[hidden],
body:is([data-football="VIEW_STELE"], [data-football="KEEPIE"], [data-football="GARDEN_OVERLOOK"], [data-football="BASKETBALL"], [data-football="BADMINTON"]) .market-hud { display: none; }

#seat-talk, #social-toast {
    position: fixed; left: 50%; transform: translateX(-50%); width: max-content; max-width: min(540px, 92vw);
    border-radius: 13px; padding: 9px 14px; font: 600 13px/1.45 Tahoma, sans-serif; text-align: center; pointer-events: none;
}
#say-bar {
    position: fixed; left: 50%; transform: translateX(-50%);
    bottom: max(15px, env(safe-area-inset-bottom)); z-index: 18;
    display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 11px;
    width: min(390px, calc(100vw - 260px)); min-width: 210px;
    background: rgba(255, 248, 232, 0.94); border: 2px solid #876244; border-radius: 22px;
    box-shadow: 0 3px 10px rgba(40, 28, 16, 0.22);
}
#say-bar:focus-within {
    border-color: #1a237e; background: #fffdf8;
    box-shadow: 0 0 0 3px rgba(26, 35, 126, 0.18), 0 4px 14px rgba(26, 35, 126, 0.2);
}
#say-bar[hidden],
body:is([data-football="VIEW_STELE"], [data-football="KEEPIE"], [data-football="GARDEN_OVERLOOK"], [data-football="BASKETBALL"], [data-football="BADMINTON"]) #say-bar { display: none !important; }
#say-input {
    flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
    color: #253348; font: 600 13.5px Tahoma, sans-serif;
    -webkit-user-select: text; user-select: text;
}
#say-input::placeholder { color: #7c6852; font-weight: 500; }
#say-send {
    flex-shrink: 0; padding: 6px 13px; border: 0; border-radius: 16px;
    background: #293d52; color: #fff8e7; font: 700 12.5px Tahoma, sans-serif; cursor: pointer;
}
#say-send:hover { background: #38526d; }
#seat-talk { z-index: 17; bottom: 13%; background: #fff7dfed; color: #624a30; pointer-events: auto; display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; border: 1.5px solid #d5b98e; box-shadow: 0 3px 10px rgba(70, 48, 22, 0.18); }
.seat-share-btn {
    padding: 5px 11px; border-radius: 10px; border: 1.5px solid #2e7d32; background: #2e7d32;
    color: #fff; font: 700 12.5px Tahoma, sans-serif; cursor: pointer;
}
.seat-share-btn:hover { background: #388e3c; }
#social-toast { z-index: 75; top: 18%; background: #303e55f5; color: #fff9eb; box-shadow: 0 3px 14px #23344935; }
#social-toast[hidden], #seat-talk[hidden] { display: none; }
#social-entry-error { font: 12px/1.4 Tahoma; color: #a33332; grid-column: 1 / -1; }
#social-entry-error:empty { display: none; }

/* Cửa hàng Căng-tin */
#school-sheet[data-paper="market"] { width: min(660px, 94vw); max-height: min(88dvh, 700px); padding: 0; overflow: hidden; border: 2px solid #79533e; border-radius: 17px; background: #fff8e8; color: #293951; }
#school-sheet[data-paper="market"] section { display: flex; flex-direction: column; gap: 0; max-height: calc(min(88dvh, 700px) - 5px); }
#school-sheet[data-paper="market"] h2 { margin: 0; padding: 14px 56px 2px 19px; background: #273851; color: #fff5d9; font: 700 24px/1.2 Georgia, serif; }
.market-sub { padding: 2px 18px 13px; background: #273851; color: #f6dcac; font-size: 13px; }
#school-sheet .market-close { position: absolute; top: 6px; right: 6px; width: 42px; height: 42px; padding: 0; border: 0; background: transparent; color: white; text-align: center; font: bold 20px/1 Tahoma; cursor: pointer; }
.market-close span { display: inline-grid; place-items: center; width: 27px; height: 27px; border-radius: 50%; background: #b54139; }
.market-strip { display: flex; align-items: center; justify-content: space-between; gap: 5px; padding: 8px 18px; border-bottom: 1px solid #d9c7a2; background: #f6e7c5; color: #61462c; font: 700 13px Tahoma, sans-serif; }
.market-nav { display: flex; flex-wrap: wrap; gap: 5px; padding: 10px 14px 3px; }
#school-sheet .market-nav button { width: auto; border: 1px solid #c4ae8b; background: #fffaf0; border-radius: 20px; color: #5f4a37; padding: 6px 12px; font: 600 13px Tahoma, sans-serif; }
#school-sheet .market-nav button[aria-pressed="true"] { background: #334662; color: white; border-color: #334662; }
.market-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 153px), 1fr)); gap: 9px; overflow: auto; overscroll-behavior: contain; padding: 12px 14px 16px; align-content: start; min-height: 0; }
.market-card { display: grid; grid-template-rows: 61px auto auto 1fr auto; justify-items: start; gap: 4px; min-width: 0; padding: 9px 11px; border: 1px solid #d2b993; border-radius: 11px; background: #fffdf6; box-shadow: 0 2px 0 #ad8e6330; }
.food-fx-tag {
    display: inline-block; padding: 3px 7px; border-radius: 7px;
    background: #eef6f0; border: 1px solid #b7d9c2; color: #1e5b3a !important;
    font: 600 11px/1.3 Tahoma, sans-serif !important;
}
#food-fx-pill {
    position: fixed; left: max(14px, env(safe-area-inset-left)); bottom: max(122px, calc(env(safe-area-inset-bottom) + 106px));
    z-index: 19; display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px 6px 11px;
    border-radius: 14px; background: rgba(255, 249, 232, 0.94); border: 2px solid #2e7d32;
    box-shadow: 0 3px 10px rgba(18, 42, 28, 0.22); color: #1b4332; font: 700 12.5px Tahoma, sans-serif;
    max-width: calc(100vw - 32px);
}
#food-fx-pill.combo {
    background: linear-gradient(90deg, #fff8dc, #ffecb3);
    border-color: #ef6c00; color: #5d2b00;
    box-shadow: 0 0 0 3px rgba(255, 213, 79, 0.45), 0 4px 12px rgba(130, 62, 0, 0.25);
}
#food-fx-pill[hidden],
body:is([data-football="VIEW_STELE"], [data-football="KEEPIE"], [data-football="GARDEN_OVERLOOK"], [data-football="BASKETBALL"], [data-football="BADMINTON"]) #food-fx-pill { display: none !important; }
.ffx-ico { font-size: 15px; line-height: 1; }
.ffx-burst, .ffx-clear {
    border: 0; background: rgba(27, 67, 50, 0.14); color: #1b4332; border-radius: 50%;
    width: 22px; height: 22px; line-height: 20px; text-align: center; font: 700 12px Tahoma, sans-serif; cursor: pointer;
}
.ffx-burst { background: rgba(255, 193, 7, 0.28); }
.ffx-burst:hover { background: rgba(255, 179, 0, 0.55); transform: scale(1.1); }
.ffx-clear:hover { background: rgba(183, 28, 28, 0.2); color: #b71c1c; }
.market-card canvas { width: 100%; height: 61px; object-fit: contain; border-radius: 6px; background: radial-gradient(ellipse at 50% 68%, #f3e5c8, transparent 67%); }
.market-card b { font: 700 14px/1.3 Tahoma, sans-serif; }
.market-card small { color: #6e5843; font: 12px/1.4 Tahoma, sans-serif; }
.market-buyline { display: flex; align-items: center; justify-content: space-between; align-self: end; gap: 4px; width: 100%; color: #7d3c26; font: 700 13px Tahoma, sans-serif; }
#school-sheet .market-buyline button { width: auto; min-height: 34px; padding: 5px 12px; border: 1px solid #1b2b40; background: #304561; color: #fff9e9; text-align: center; font: 700 13px Tahoma, sans-serif; }
#school-sheet .market-buyline button:hover { background: #475e79; }
.market-status { padding: 8px 16px; background: #f2eedc; color: #315442; min-height: 33px; font: 700 13px/1.35 Tahoma, sans-serif; border-top: 1px solid #decfae; }
.market-status:empty { display: none; }
.market-status[data-error="true"] { background: #f9e1d4; color: #8c2e29; }

/* Bảng Xã hội / Túi đồ */
#school-sheet[data-paper="social"] { width: min(625px, 94vw); padding: 0; overflow: hidden; border-color: #805b43; }
#school-sheet[data-paper="social"] section { display: flex; flex-direction: column; gap: 0; max-height: min(82dvh, 690px); }
#school-sheet[data-paper="social"] h2 { background: #293d52; color: #fff3d9; padding: 13px 48px 13px 17px; margin: 0; font: 700 24px Georgia, serif; }
#school-sheet .social-close { position: absolute; top: 4px; right: 4px; width: 43px; height: 43px; padding: 0; background: #ad443c; color: white; font: bold 23px Tahoma; text-align: center; border: 7px solid #293d52; border-radius: 50%; }
.social-nav, .social-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.social-nav { padding: 8px 11px; background: #f4e5c4; border-bottom: 1px solid #d9c6a4; }
#school-sheet .social-nav button, #school-sheet .social-actions button { width: auto; padding: 7px 10px; font: 600 13px Tahoma; text-align: center; min-height: 34px; }
#school-sheet .social-nav button[aria-pressed="true"], #school-sheet .social-actions button:first-child { background: #344d62; color: white; }
.social-body { overflow: auto; overscroll-behavior: contain; padding: 13px; display: grid; align-content: start; gap: 9px; min-height: 0; }
#school-sheet .social-line { font-size: 14px; margin: 0; overflow-wrap: anywhere; }
.social-card { background: #fffdf5; border: 1px solid #d7c19b; padding: 10px; border-radius: 11px; display: flex; flex-direction: column; gap: 5px; overflow-wrap: anywhere; }
.social-card .social-actions { margin-top: auto; padding-top: 6px; align-items: center; }
.social-card .social-actions > button { flex: 1 1 0; }
.social-card .social-actions > button.share-eat-btn { flex: 1 0 100%; }
.social-grid, .social-badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 8px; }
.social-card canvas { height: 61px; width: 100%; flex-shrink: 0; object-fit: contain; }
.social-card .silhouette { filter: brightness(0); opacity: .82; }
.social-card.locked { background: #f5f1e6; border-style: dashed; border-color: #c5b699; }
.social-card.combo-card.unlocked { background: linear-gradient(180deg, #fffdf0, #fff4d2); border-color: #e0b145; }
.book-hint { margin: 0; font: 600 12.5px/1.4 Tahoma, sans-serif; color: #6a5640; background: #f7eed8; padding: 7px 10px; border-radius: 9px; }
.book-sec-head { margin: 6px 0 0; font: 800 14.5px Tahoma, sans-serif; color: #263a52; border-bottom: 1.5px solid #decba6; padding-bottom: 4px; }
.combo-riddle {
    margin: 2px 0 0; padding: 7px 8px; border-radius: 8px;
    background: #ede5d0; border-left: 3px solid #9c6b30;
    font: italic 12px/1.4 Tahoma, sans-serif; color: #4d3b27;
}
.book-locked-hint { color: #7c6d58 !important; font-style: italic; }
.gift-letter {
    margin: 2px 0; padding: 8px 10px; border-radius: 8px;
    background: linear-gradient(180deg, #fffaf0, #f8ebd2);
    border: 1.5px dashed #b98356; color: #4e3120;
    font: italic 12.5px/1.45 Georgia, 'Times New Roman', serif;
    white-space: pre-wrap; overflow-wrap: anywhere;
}
.gift-letter-input {
    width: 100%; padding: 8px 10px; border-radius: 8px;
    border: 1.5px solid #c5a37a; background: #fffcf5; color: #3e2723;
    font: 13px/1.4 Tahoma, sans-serif; resize: vertical;
}
.share-banner {
    margin: 0; padding: 8px 11px; border-radius: 9px;
    background: #e8f5e9; border: 1.5px solid #81c784; color: #1b5e20;
    font: 700 12.5px/1.4 Tahoma, sans-serif;
}
#school-sheet .social-actions button.share-eat-btn {
    background: #2e7d32; border-color: #1b5e20; color: #fff; font-weight: 700;
}
#school-sheet .social-actions button.share-eat-btn:hover { background: #388e3c; }
#food-fx-pill.eating {
    background: linear-gradient(90deg, #e8f5e9, #fff8e1);
    border-color: #2e7d32; color: #1b5e20;
}
.social-card small, .social-badges small { font-size: 12px; color: #615946; }
.social-badges > div { padding: 8px; border-radius: 9px; background: #eee9dd; color: #645c4b; }
.social-badges small { display: block; }
.social-badges .achieved { color: #764821; background: #f8e1a4; }
.social-field { display: grid; gap: 5px; }
.social-log { max-height: 25dvh; overflow: auto; display: grid; gap: 4px; background: #f4efdf; border-radius: 8px; padding: 6px; }
.social-log:empty, .social-status:empty { display: none; }
.social-status { font-size: 13px; padding: 7px 13px; background: #f4ead8; color: #653c30; }

@media (pointer: coarse) {
    #market-bag { bottom: max(166px, calc(env(safe-area-inset-bottom) + 146px)); }
    #social-hub { bottom: max(216px, calc(env(safe-area-inset-bottom) + 196px)); }
    #food-fx-pill { bottom: max(268px, calc(env(safe-area-inset-bottom) + 248px)); }
    #say-bar { width: min(290px, calc(100vw - 170px)); bottom: max(14px, env(safe-area-inset-bottom)); }
}
@media (max-width: 560px) {
    #school-way { max-width: calc(100vw - 225px); }
    .social-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    #seat-talk { bottom: auto; top: 22%; max-width: 90vw; }
    #say-bar { width: min(280px, calc(100vw - 120px)); min-width: 170px; padding: 4px 5px 4px 9px; }
    .social-nav { gap: 4px; }
    #school-sheet .social-nav button { flex: auto; padding: 7px 6px; }
}
@media (max-width: 460px) {
    .market-items { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; padding: 8px; }
    .market-card { padding: 8px; }
    .market-nav { padding: 6px 8px; }
    .market-strip { padding: 7px 11px; }
}
