:root {
  color-scheme: light;
  --ink: #172c39;
  --muted: #526876;
  --green: #087561;
  --line: #d9e3e4;
  --paper: #f4f7f6;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font:
    16px/1.6 system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
}
a {
  color: inherit;
  text-decoration: none;
}
button,
input,
select {
  font: inherit;
}
button,
select {
  cursor: pointer;
}
button,
.primary {
  border: 1px solid #b9cccd;
  border-radius: 10px;
  background: #fff;
  padding: 10px 17px;
  color: var(--ink);
  font-weight: 650;
  min-height: 44px;
}
button:hover {
  background: #e8f3ef;
}
button:disabled {
  cursor: default;
  opacity: 0.65;
}
button[aria-pressed="true"] {
  background: #0b6656;
  color: white;
  border-color: #0b6656;
}
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
canvas:focus-visible {
  outline: 3px solid #c45a09;
  outline-offset: 4px;
}
[hidden] {
  display: none !important;
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1 {
  line-height: 1.2;
  letter-spacing: -1.5px;
}
h2 {
  line-height: 1.3;
  letter-spacing: -0.6px;
}
.skip {
  position: fixed;
  top: -90px;
  left: 16px;
  z-index: 20;
  background: #fff;
  padding: 12px;
}
.skip:focus {
  top: 12px;
}
.portal-header {
  background: #152e3b;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px max(24px, calc((100vw - 1320px) / 2));
  gap: 30px;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  white-space: nowrap;
  font-size: 25px;
  font-weight: 800;
  line-height: 1.1;
}
.brand small {
  display: block;
  font-size: 9px;
  letter-spacing: 2.3px;
  margin-top: 9px;
  color: #b8d6d8;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  background: #bee9b2;
  color: #173d36;
  border-radius: 14px;
  font-weight: 900;
  position: relative;
  font-size: 29px;
}
.brand-mark span {
  font-size: 15px;
  position: absolute;
  right: 5px;
  bottom: 3px;
}
.portal-header nav {
  display: flex;
  gap: 28px;
  font-size: 14px;
  font-weight: 600;
  align-items: center;
}
.portal-header nav a:hover {
  color: #bee9b2;
}
.portal-main {
  max-width: 1370px;
  margin: auto;
  padding: 42px 25px 60px;
}
.portal-hero {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 60px;
  align-items: center;
  margin-bottom: 58px;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 1.8px;
  font-weight: 800;
  color: #326b61;
  text-transform: uppercase;
}
.portal-hero h1 {
  font-size: 58px;
  margin: 16px 0 20px;
}
.portal-hero p {
  max-width: 440px;
  color: var(--muted);
  font-size: 17px;
}
.primary {
  display: inline-block;
  background: #087561;
  color: #fff;
  border-color: #087561;
}
.primary:hover {
  background: #065e4e;
  color: #fff;
}
.hero-cta {
  margin-top: 9px;
}
.hero-scene {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  box-shadow: 0 15px 35px #163c3420;
  display: block;
  background: #183d42;
}
.hero-scene img {
  display: block;
  width: 100%;
  height: auto;
}
.hero-scene > span {
  display: block;
  padding: 16px 25px 22px;
  color: #c2dfdc;
  font-size: 10px;
  letter-spacing: 1.5px;
}
.hero-scene strong {
  display: flex;
  justify-content: space-between;
  font-size: 23px;
  letter-spacing: -0.5px;
  margin-top: 4px;
  color: #fff;
}
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 24px;
}
.section-heading h2 {
  font-size: 30px;
  margin: 6px 0 0;
}
.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.catalog-toolbar {
  display: flex;
  gap: 16px;
  align-items: end;
}
.catalog-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
.catalog-toolbar .search-label {
  flex: 1;
}
.catalog-toolbar input,
.catalog-toolbar select {
  border: 1px solid #bbcfd0;
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  color: var(--ink);
  height: 49px;
  width: 100%;
  font-size: 15px;
}
.category-tabs {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  margin: 22px 0 28px;
}
.category-tabs button {
  border-radius: 30px;
  padding: 8px 20px;
  font-size: 14px;
}
.game-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 22px;
}
.game-card {
  position: relative;
  overflow: hidden;
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--line);
  transition:
    transform 0.18s,
    box-shadow 0.18s;
}
.game-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 26px #193d3214;
}
.cover-wrap {
  position: relative;
  background: #d9e9e7;
  overflow: hidden;
}
.cover-wrap img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 8/5;
  object-fit: cover;
}
.card-category {
  position: absolute;
  left: 12px;
  bottom: 12px;
  border-radius: 6px;
  padding: 3px 8px;
  background: #ffffffed;
  font-size: 10px;
  font-weight: 750;
  color: #193c3b;
}
.card-copy {
  padding: 17px 18px 20px;
}
.card-copy h3 {
  font-size: 18px;
  margin: 0 0 8px;
  line-height: 1.35;
}
.card-copy p {
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  min-height: 42px;
  margin: 0 0 14px;
}
.card-grade {
  font-size: 11px;
  color: #536e71;
  font-weight: 650;
}
.favorite {
  position: absolute;
  right: 10px;
  top: 10px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  width: 40px;
  height: 40px;
  min-height: 40px;
  font-size: 28px;
  line-height: 1;
  background: #ffffffeb;
}
.favorite[aria-pressed="true"] {
  background: #fff1d9;
  color: #92420c;
}
.empty-state {
  padding: 70px 20px;
  text-align: center;
}
.learn-strip {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 26px 30px;
  margin-top: 48px;
  border-radius: 18px;
  background: #e6eee8;
}
.learn-strip > div {
  flex: 1;
}
.learn-strip h2 {
  margin: 7px 0;
  font-size: 22px;
}
.learn-strip a {
  font-size: 13px;
  font-weight: 700;
  border-bottom: 1px solid #6e9385;
  padding-bottom: 6px;
}
.portal-footer {
  max-width: 1320px;
  margin: auto;
  padding: 30px 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.portal-footer a {
  font-weight: 800;
  font-size: 16px;
  color: var(--ink);
}
.portal-footer p {
  margin: 10px 0;
}
.preview-note {
  padding: 12px;
  text-align: center;
  background: #fff1d1;
  color: #694800;
}
.back-link {
  font-size: 13px;
  color: #48666a;
}
.player-heading {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin: 23px 0;
}
.player-heading h1 {
  font-size: 35px;
  margin: 7px 0;
}
.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 265px;
  gap: 28px;
}
.play-panel {
  min-width: 0;
}
#player-shell {
  background: #142e39;
  border-radius: 17px;
  overflow: hidden;
  box-shadow: 0 10px 25px #172c3914;
}
.game-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #cee3e7;
  padding: 13px 20px;
  font-size: 12px;
  gap: 12px;
  min-height: 55px;
}
.game-hud strong {
  font-size: 20px;
  color: #fff;
  margin-left: 8px;
}
#game-detail {
  text-align: center;
  color: #e1f1c8;
}
.game-stage {
  position: relative;
  aspect-ratio: 900/560;
  background: #cde8e8;
  overflow: hidden;
}
#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.game-buttons {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.game-buttons button {
  position: absolute;
  pointer-events: auto;
  padding: 0;
  border: 0;
  min-height: 0;
  background: transparent;
  border-radius: 12px;
  color: transparent;
  overflow: hidden;
  touch-action: manipulation;
}
.game-buttons button:focus-visible {
  outline: 4px solid #a74100;
  outline-offset: -3px;
}
.game-overlay {
  position: absolute;
  inset: 0;
  background: #102c3c80;
  display: grid;
  place-items: center;
  padding: 16px;
  backdrop-filter: blur(5px);
}
.overlay-card {
  background: #fffffff5;
  border: 1px solid #fff;
  border-radius: 20px;
  padding: 28px;
  max-width: 370px;
  text-align: center;
  box-shadow: 0 18px 45px #102b3e30;
}
.overlay-card h2 {
  font-size: 27px;
  margin: 8px 0 12px;
}
.overlay-card p {
  font-size: 14px;
  color: #526775;
  margin-bottom: 16px;
}
.overlay-card label {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  font-size: 13px;
  margin-bottom: 18px;
}
.overlay-card select {
  border: 1px solid #b9cccd;
  padding: 8px;
  border-radius: 8px;
  background: white;
  color: #203c45;
}
.overlay-card button {
  margin: 3px;
}
.game-controls {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
}
.game-controls > div {
  display: flex;
  gap: 8px;
}
.game-controls button {
  background: #25434f;
  border-color: #486571;
  color: #edf6f6;
  font-size: 12px;
  padding: 6px 13px;
  min-height: 38px;
}
.touch-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 16px 0;
}
.touch-controls > span {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
}
.direction-pad {
  display: flex;
  gap: 5px;
}
.direction-pad button {
  width: 44px;
  padding: 4px;
  font-size: 21px;
  touch-action: none;
  user-select: none;
}
.game-status {
  font-size: 13px;
  min-height: 22px;
  color: #3f6163;
}
.game-guide {
  padding: 24px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 16px;
  align-self: start;
}
.game-guide h2 {
  font-size: 22px;
  margin: 10px 0 15px;
}
.game-guide h3 {
  font-size: 15px;
  margin: 22px 0 9px;
}
.game-guide p {
  font-size: 14px;
  color: var(--muted);
}
.guide-tip {
  background: #eef4ec;
  border-radius: 10px;
  padding: 16px;
  font-size: 13px;
}
.guide-tip p {
  font-size: 12px;
  margin: 7px 0 0;
}
.local-record {
  font-size: 11px !important;
  margin: 20px 0 0;
}
.related {
  margin-top: 35px;
}
.related .section-heading a {
  font-size: 13px;
}
.storage-note {
  color: #825514;
  font-size: 13px;
}
#player-shell:fullscreen {
  border-radius: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
#player-shell:fullscreen .game-stage {
  width: min(100vw, calc((100vh - 120px) * 900 / 560));
  max-height: calc(100vh - 120px);
  margin: auto;
}
#player-shell:fullscreen .game-hud,
#player-shell:fullscreen .game-controls {
  width: 100%;
  max-width: 1200px;
  margin: auto;
}
body[data-playing="true"] .game-buttons {
  visibility: visible;
}
body:not([data-playing="true"]) .game-buttons {
  visibility: hidden;
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
@media (max-width: 1100px) {
  .game-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .portal-hero {
    gap: 30px;
  }
  .portal-hero h1 {
    font-size: 46px;
  }
  .play-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .game-guide {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 25px;
  }
  .game-guide > .eyebrow,
  .game-guide > h2 {
    grid-column: 1/-1;
  }
  .learn-strip {
    flex-wrap: wrap;
  }
  .learn-strip > div {
    flex-basis: 100%;
  }
  .portal-header nav {
    gap: 15px;
    font-size: 12px;
  }
}
@media (max-width: 650px) {
  .portal-header {
    padding: 16px 18px;
    display: block;
  }
  .brand {
    font-size: 23px;
  }
  .portal-header nav {
    margin-top: 20px;
    gap: 20px;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 3px;
  }
  .portal-main {
    padding: 27px 16px 40px;
  }
  .portal-hero {
    grid-template-columns: 1fr;
    gap: 24px;
    margin-bottom: 35px;
  }
  .portal-hero h1 {
    font-size: 43px;
  }
  .portal-hero p {
    font-size: 15px;
  }
  .hero-scene img {
    max-height: 210px;
    object-fit: cover;
  }
  .hero-scene > span {
    padding: 12px 18px;
  }
  .hero-scene strong {
    font-size: 21px;
  }
  .section-heading h2 {
    font-size: 25px;
  }
  .catalog-toolbar {
    flex-wrap: wrap;
    gap: 12px;
  }
  .catalog-toolbar .search-label {
    flex-basis: 100%;
  }
  .catalog-toolbar label:not(.search-label) {
    flex: 1;
    min-width: 0;
  }
  .category-tabs {
    gap: 7px;
  }
  .category-tabs button {
    padding: 7px 13px;
    font-size: 12px;
  }
  .game-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .card-copy {
    padding: 12px;
  }
  .card-copy h3 {
    font-size: 15px;
  }
  .card-copy p {
    font-size: 12px;
    min-height: 58px;
  }
  .card-grade {
    font-size: 10px;
  }
  .card-category {
    font-size: 9px;
    bottom: 7px;
    left: 7px;
  }
  .favorite {
    width: 34px;
    height: 34px;
    min-height: 34px;
    font-size: 24px;
    right: 6px;
    top: 6px;
  }
  .learn-strip {
    padding: 20px;
  }
  .learn-strip a {
    display: block;
  }
  .player-heading {
    align-items: start;
    gap: 10px;
  }
  .player-heading h1 {
    font-size: 26px;
  }
  .player-heading .eyebrow {
    font-size: 9px;
  }
  .favorite-inline {
    font-size: 11px;
    padding: 7px 10px;
    min-height: 36px;
    white-space: nowrap;
  }
  .game-hud {
    padding: 10px;
    font-size: 10px;
    min-height: 46px;
    gap: 5px;
  }
  .game-hud strong {
    font-size: 16px;
    margin-left: 3px;
  }
  .overlay-card {
    padding: 14px;
    max-width: 300px;
  }
  .overlay-card .eyebrow {
    font-size: 8px;
  }
  .overlay-card h2 {
    font-size: 19px;
    margin: 3px 0 7px;
  }
  .overlay-card p {
    font-size: 11px;
    margin-bottom: 8px;
  }
  .overlay-card label {
    font-size: 11px;
    margin-bottom: 7px;
  }
  .overlay-card select {
    padding: 3px;
  }
  .overlay-card button {
    padding: 7px 12px;
    min-height: 36px;
    font-size: 12px;
  }
  .game-controls {
    padding: 8px;
    gap: 5px;
  }
  .game-controls button {
    font-size: 10px;
    padding: 5px 8px;
    min-height: 36px;
  }
  .touch-controls {
    gap: 8px;
    flex-wrap: wrap;
  }
  .touch-controls > span {
    font-size: 10px;
  }
  .game-guide {
    display: block;
    padding: 20px;
  }
  .related .section-heading h2 {
    font-size: 23px;
  }
}

#player-shell .touch-controls {
  margin: 0;
  padding: 4px 12px 12px;
}
#player-shell .touch-controls > span {
  color: #c5dadf;
}
#player-shell:fullscreen .game-stage {
  width: min(100vw, calc((100vh - 185px) * 900 / 560));
  max-height: calc(100vh - 185px);
  flex-shrink: 0;
}
#player-shell:fullscreen .touch-controls {
  width: 100%;
  max-width: 1200px;
  margin: auto;
}
#player-shell:fullscreen .game-overlay {
  overflow: auto;
}
#player-shell:fullscreen .overlay-card {
  padding: 14px;
}
#player-shell:fullscreen .overlay-card h2 {
  font-size: 20px;
}
#player-shell:fullscreen .overlay-card p {
  font-size: 12px;
  margin-bottom: 8px;
}

/* Artwork-led player: the game receives the full width; instructions sit below it. */
.player-main {
  max-width: 1230px;
}
.play-layout {
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
}
.game-guide {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 8px 30px;
  padding: 26px 30px;
  width: 100%;
}
.game-guide > .eyebrow {
  grid-column: 1;
}
.game-guide > h2 {
  grid-column: 1;
  grid-row: 2;
  font-size: 21px;
}
.game-guide > p:first-of-type {
  grid-column: 1;
  grid-row: 3;
}
.game-guide > h3 {
  grid-column: 2;
  grid-row: 2;
  margin: 0;
}
.game-guide > p:nth-of-type(2) {
  grid-column: 2;
  grid-row: 3;
}
.game-guide > .guide-tip {
  grid-column: 3;
  grid-row: 1/4;
}
.game-guide > .local-record {
  grid-column: 1/4;
  margin: 0;
}
.game-guide p {
  margin-bottom: 0;
}
.game-hud {
  background: linear-gradient(100deg, #112e34, #173e43);
  border-bottom: 1px solid #d5b57433;
  padding: 14px 23px;
}
.game-hud strong {
  color: #ffe9ac;
  font-size: 24px;
}
.game-controls {
  border-top: 1px solid #d5b57422;
  background: #112e34;
}
.game-controls button {
  background: #163d41;
  border-color: #bba36755;
  color: #f5e9c8;
}
.game-stage {
  background: #153630;
}
#player-shell {
  border: 1px solid #816e4545;
  box-shadow: 0 20px 45px #102c3926;
}
.game-overlay {
  background: linear-gradient(180deg, #062a3220, #07232999);
  backdrop-filter: blur(1.5px);
}
.overlay-card {
  background: linear-gradient(145deg, #123c3feb, #102d34f5);
  border: 1px solid #c0a46f88;
  box-shadow: 0 20px 65px #061b2580;
  color: #fff2c9;
  border-radius: 17px;
}
.overlay-card .eyebrow {
  color: #d8c18e;
}
.overlay-card p {
  color: #d8e7df;
}
.overlay-card label {
  color: #e8e6d4;
}
.overlay-card .primary {
  background: #ecd49a;
  color: #203f3c;
  border-color: #ffedba;
}
.overlay-card .primary:hover {
  background: #fff0c3;
}
.overlay-card select {
  color: #193c3d;
}
.overlay-card h2 {
  font-weight: 800;
}
.game-buttons button:hover {
  background: #fff2c80a;
  box-shadow: inset 0 0 0 2px #ffe3a577;
}
.game-buttons button:disabled:hover {
  background: transparent;
  box-shadow: none;
}
#player-shell[data-game="chem-trai-cay"] {
  position: relative;
}
#player-shell[data-game="chem-trai-cay"] .game-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(#061f2caa, transparent);
  border: 0;
  text-shadow: 0 2px 5px #082319;
}
#player-shell[data-game="chem-trai-cay"] .game-stage {
  border-radius: 15px 15px 0 0;
}
@media (max-width: 650px) {
  .game-guide {
    display: block;
    padding: 20px;
  }
  .game-guide > h3 {
    margin-top: 20px;
  }
  .game-guide > .guide-tip {
    margin-top: 20px;
  }
  .game-guide > .local-record {
    margin-top: 15px;
  }
  .game-hud {
    padding: 9px 11px;
  }
  .game-hud strong {
    font-size: 17px;
  }
  .overlay-card {
    padding: 14px;
  }
  .player-heading h1 {
    font-size: 25px;
  }
}
