:root {
    --bg: #f5efe6;
    --ink: #1c1814;
    --accent: #8b1e2d;
    --accent-soft: #b04050;
    --gold: #c9a66b;
    --paper: #fbf7f0;
    --border: #d8cfc1;
    --max: 1080px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Lora', Georgia, 'Times New Roman', serif;
    font-size: 17px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topnav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: var(--max);
    margin: 0 auto;
    padding: 1.5rem 2rem;
}

.logo {
    font-family: 'Inter', system-ui, sans-serif;
    font-weight: 800;
    font-size: 1.4rem;
    letter-spacing: -0.02em;
    color: var(--ink);
}
.logo span { color: var(--accent); }

.topnav nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}
.topnav nav a {
    color: var(--ink);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
}
.topnav nav a.cta {
    background: var(--accent);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
}
.topnav nav a.cta:hover { background: var(--accent-soft); text-decoration: none; }

main { max-width: var(--max); margin: 0 auto; padding: 0 2rem; }

.hero {
    padding: 3rem 0 4rem;
    border-bottom: 1px solid var(--border);
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    line-height: 1.1;
    margin: 0 0 1rem;
    letter-spacing: -0.02em;
}

.lead {
    font-size: 1.2rem;
    max-width: 60ch;
    margin: 0 0 2rem;
    color: #4a4239;
}

.cta-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.btn {
    display: inline-block;
    padding: 0.85rem 1.6rem;
    border-radius: 4px;
    font-family: 'Inter', system-ui, sans-serif;
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
}
.btn.primary { background: var(--accent); color: white; }
.btn.primary:hover { background: var(--accent-soft); text-decoration: none; }
.btn.ghost {
    background: transparent;
    color: var(--accent);
    border: 1.5px solid var(--accent);
}
.btn.ghost:hover { background: var(--accent); color: white; text-decoration: none; }

.note {
    color: #6b6358;
    font-size: 0.95rem;
    margin-top: 0.5rem;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 2rem;
    padding: 3rem 0;
    border-bottom: 1px solid var(--border);
}
.features h3 {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 1.1rem;
    margin: 0 0 0.5rem;
    color: var(--accent);
}
.features p { margin: 0; color: #4a4239; }

.prose { padding: 4rem 0; max-width: 70ch; }
.prose h2 {
    font-size: 2rem;
    line-height: 1.2;
    margin: 0 0 1.5rem;
    letter-spacing: -0.01em;
}
.prose h3 { font-size: 1.3rem; margin-top: 2rem; }
.prose p { margin: 0 0 1.2rem; }
.prose strong { color: var(--accent); }

table.tai {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    font-size: 0.95rem;
}
table.tai th, table.tai td {
    text-align: left;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border);
}
table.tai th {
    background: var(--paper);
    font-family: 'Inter', system-ui, sans-serif;
    font-weight: 600;
}
table.tai tr:hover { background: var(--paper); }

/* ============ Mahjong tile graphics ============ */

.tile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 60px;
    background: linear-gradient(180deg, #fbf7ee 0%, #f1ead7 100%);
    border: 1.5px solid #c5b797;
    border-radius: 6px;
    box-shadow:
        inset 0 -3px 0 rgba(120, 100, 60, 0.15),
        0 2px 4px rgba(0, 0, 0, 0.12),
        0 1px 1px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    user-select: none;
    transition: transform 120ms ease;
    /* Legacy support for Unicode-glyph fallback during transition */
    font-family: 'Noto Sans Symbols 2', 'Noto Sans CJK SC', 'Apple Color Emoji', 'Segoe UI Emoji', sans-serif;
    font-size: 38px;
    line-height: 1;
    color: #2a2620;
}
.tile.small { width: 30px; height: 42px; font-size: 26px; }
.tile.large { width: 60px; height: 82px; font-size: 52px; }

.tile > img,
.tile picture > img {
    width: 84%;
    height: 84%;
    object-fit: contain;
    pointer-events: none;
    display: block;
}

.tile.red { color: #b3271e; }
.tile.green { color: #2d6e3a; }
.tile.blue { color: #1c3a6e; }
.tile.gold { color: #c08a2a; }

.tile.flipped {
    background: linear-gradient(135deg, #1f4837 0%, #163528 100%);
    border-color: #0e1f17;
    color: transparent;
    box-shadow:
        inset 0 0 0 2px #2a5a44,
        inset 0 -3px 0 rgba(0, 0, 0, 0.4),
        0 2px 4px rgba(0, 0, 0, 0.18);
}
.tile.flipped > img { display: none; }

.tile-rack {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    background: var(--paper);
    border-radius: 8px;
    border: 1px solid var(--border);
}
.tile-rack.dark {
    background: var(--felt, #1f4837);
    border-color: #0e1f17;
}

.tile-set {
    display: inline-flex;
    gap: 4px;
    padding: 6px 10px;
    background: var(--paper);
    border-radius: 8px;
    border: 1px solid var(--border);
    margin: 4px 8px 4px 0;
    align-items: flex-end;
    vertical-align: middle;
}
.tile-set .label {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.85rem;
    color: #6b6358;
    margin-left: 6px;
    align-self: center;
}

.tile-hand-demo {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 1.5rem 0;
    padding: 16px;
    background: linear-gradient(180deg, var(--felt, #1f4837) 0%, #163528 100%);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.hero-tiles {
    display: flex;
    gap: 6px;
    margin: 2rem 0 0;
    flex-wrap: wrap;
    perspective: 800px;
}
.hero-tiles .tile { transform: translateY(0); }
.hero-tiles .tile:nth-child(odd) { transform: translateY(-2px) rotate(-1deg); }
.hero-tiles .tile:nth-child(even) { transform: translateY(2px) rotate(1deg); }

.felt-table {
    aspect-ratio: 1.4;
    background: radial-gradient(ellipse at center, #2a5a44 0%, #1f4837 60%, #163528 100%);
    border-radius: 16px;
    border: 8px solid #5a3d22;
    padding: 24px;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.2), inset 0 0 30px rgba(0, 0, 0, 0.25);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-rows: 1fr auto 1fr;
    gap: 12px;
    margin: 2rem auto;
    max-width: 720px;
}
.felt-table .seat {
    display: flex;
    align-items: center;
    justify-content: center;
}
.felt-table .seat.north { grid-column: 2; grid-row: 1; }
.felt-table .seat.east  { grid-column: 3; grid-row: 2; }
.felt-table .seat.south { grid-column: 2; grid-row: 3; }
.felt-table .seat.west  { grid-column: 1; grid-row: 2; }
.felt-table .center {
    grid-column: 2; grid-row: 2;
    color: #c9a66b;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.85rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    padding: 12px 8px;
    min-width: 140px;
}
.felt-table .center .discards {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    justify-content: center;
}
.felt-table .seat.south .tile-rack { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); }
.felt-table .seat.north .tile.flipped,
.felt-table .seat.east .tile.flipped,
.felt-table .seat.west .tile.flipped { transform: scale(0.85); }

footer {
    border-top: 1px solid var(--border);
    margin-top: 4rem;
    padding: 2rem;
    text-align: center;
    color: #6b6358;
    font-size: 0.9rem;
}

@media (max-width: 640px) {
    .topnav { flex-direction: column; gap: 1rem; padding: 1rem; }
    .topnav nav { gap: 1rem; flex-wrap: wrap; justify-content: center; }
    main { padding: 0 1.2rem; }
}
