.k3-root {
  width: 100%;
  max-width: 390px;
  margin: 0 auto;
  background: #f2f3f8;
  position: relative;
}

.page#page-k3 {
  padding: 0;
}

.page#page-k3.active,
.app-screen:has(#page-k3.active),
.page-stack:has(#page-k3.active) {
  min-height: 0;
  padding-bottom: 0 !important;
  margin-bottom: 0 !important;
}

.k3-bg {
  position: absolute;
  inset: 0 0 auto;
  height: 344px;
  background: linear-gradient(180deg, #ff6666 0%, #ff7272 100%);
  border-bottom-left-radius: 28px;
  border-bottom-right-radius: 28px;
  overflow: hidden;
}

.k3-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 12% 8%, rgba(255,255,255,0.15) 0 18%, transparent 19%),
    radial-gradient(circle at 88% 12%, rgba(255,255,255,0.1) 0 17%, transparent 18%);
}

.k3-content {
  position: relative;
  z-index: 1;
  padding: 62px 10px 8px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.k3-content::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.k3-panel {
  margin-top: 16px;
}

.k3-ticket-card {
  margin-top: 12px;
  background: #fff;
  border-radius: 18px;
  padding: 12px 12px 16px;
  box-shadow: 0 10px 22px rgba(33, 41, 75, 0.09);
}

.k3-ticket-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
}

.k3-ticket-meta-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.k3-ticket-meta span,
.k3-ticket-time span {
  display: block;
  color: #7b8498;
  font-size: 12px;
  line-height: 1;
  font-weight: 400;
}

.k3-ticket-meta strong {
  display: block;
  margin-top: 6px;
  color: #152243;
  font-size: clamp(14px, 4.2vw, 18px);
  font-weight: 600;
  letter-spacing: -0.55px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.k3-how-button {
  height: 24px;
  min-width: 88px;
  padding: 0 8px;
  border: 1px solid #ff7f7f;
  border-radius: 999px;
  background: #fff8f8;
  color: #ff6262;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 9px;
  font-weight: 500;
  flex-shrink: 0;
}

.k3-how-button img {
  width: 11px;
  height: 11px;
  filter: brightness(0) saturate(100%) invert(59%) sepia(59%) saturate(2272%) hue-rotate(319deg) brightness(104%) contrast(102%);
}

.k3-ticket-time {
  text-align: right;
}

.k3-ticket-digits {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}

.k3-ticket-digits span {
  width: 18px;
  height: 26px;
  border-radius: 3px;
  background: #fff;
  color: #ff6666;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(18, 28, 55, 0.08);
  font-size: 20px;
  font-weight: 800;
}

.k3-ticket-digits .k3-ticket-colon {
  width: 8px;
  background: transparent;
  color: #ff6565;
  box-shadow: none;
}

.k3-dice-stage-wrap {
  position: relative;
  margin-top: 12px;
}

.k3-dice-stage {
  background: linear-gradient(180deg, #17bf78 0%, #0ca761 100%);
  border-radius: 10px;
  padding: 10px 9px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.16), 0 4px 12px rgba(8, 120, 70, 0.2);
}

.k3-dice-stage-arrows {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 34px;
  transform: translateY(-50%);
  background: #0fb067;
  border-radius: 4px;
}

.k3-dice-stage-arrows::before {
  content: "";
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  transform: translateY(-50%);
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}

.k3-dice-stage-arrows-left {
  left: -5px;
}

.k3-dice-stage-arrows-left::before {
  right: -6px;
  border-left: 7px solid #0fb067;
}

.k3-dice-stage-arrows-right {
  right: -5px;
}

.k3-dice-stage-arrows-right::before {
  left: -6px;
  border-right: 7px solid #0fb067;
}

.k3-dice-slot {
  background: linear-gradient(180deg, #4e4e4e 0%, #363636 100%);
  border-radius: 6px;
  height: 98px;
  min-height: 98px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 3px 8px rgba(0,0,0,0.42);
  border: 2px solid #1b1b1b;
}

.k3-dice-slot::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.14) 0%, rgba(255,255,255,0.03) 38%, rgba(0,0,0,0.18) 100%);
  pointer-events: none;
}

.k3-dice-reel {
  position: absolute;
  inset: 0;
  transform: translateY(0);
}

.k3-dice-cell {
  height: 98px;
  min-height: 98px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.k3-dice-cell .k3-dice-svg {
  width: clamp(58px, 18vw, 76px);
  height: clamp(58px, 18vw, 76px);
  display: block;
}

.k3-dice-image {
  width: 76px;
  height: 76px;
  display: block;
  object-fit: contain;
}

.k3-dice-mini-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
}

.k3-dice-mini-wrap .k3-dice-svg {
  width: 24px;
  height: 24px;
}

.k3-dice-image.mini {
  width: 24px;
  height: 24px;
}

.k3-dice-image.mini {
  width: 24px;
  height: 24px;
}

.k3-bet-panel {
  margin-top: 16px;
  background: #fff;
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 8px 18px rgba(18, 28, 55, 0.08);
  position: relative;
}

.k3-bet-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #ececf3;
}

.k3-bet-tabs button {
  height: 42px;
  border: 0;
  background: #fff;
  color: #77819a;
  font-size: 12px;
  font-weight: 600;
}

.k3-bet-tabs button + button {
  border-left: 1px solid #ececf3;
}

.k3-bet-tabs button.active {
  background: #ff6666;
  color: #fff;
}

.k3-bet-view {
  padding: 14px 0 4px;
  min-height: 226px;
}

.k3-total-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 6px;
}

.k3-total-card {
  border: 0;
  background: transparent;
  text-align: center;
  width: 100%;
  padding: 0;
}

.k3-sum-ball-shell {
  position: relative;
  width: 52px;
  height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.k3-sum-ball-shell img {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.k3-sum-ball-shell span {
  position: absolute;
  color: #f25555;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

.k3-sum-ball-shell.is-green span {
  color: #1cbf67;
}

.k3-sum-ball-shell.is-red span {
  color: #f25555;
}

.k3-total-card .odds {
  display: block;
  margin-top: 6px;
  color: #727d95;
  font-size: 11px;
  line-height: 1;
  font-weight: 600;
}

.k3-section-title {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #1e2432;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
}

.k3-section-title + .k3-chip-grid,
.k3-section-title + .k3-wide-chip {
  margin-bottom: 12px;
}

.k3-section-title span {
  font-weight: 500;
}

.k3-section-title i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ff6b6b;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-style: normal;
  font-size: 10px;
  cursor: pointer;
}

.k3-chip-grid {
  display: grid;
  gap: 10px 6px;
}

.k3-chip-grid.six {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.k3-gap-small {
  margin-top: -2px;
}

.k3-chip,
.k3-wide-chip {
  border: 0;
  border-radius: 8px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  box-shadow: 0 4px 10px rgba(30, 36, 50, 0.12);
}

.k3-chip-purple { background: linear-gradient(180deg, #ff8c8c 0%, #ff6f6f 100%); }
.k3-chip-pink { background: linear-gradient(180deg, #76d7a0 0%, #2ac06c 100%); }
.k3-chip-green { background: linear-gradient(180deg, #f8bbbb 0%, #f39aa3 100%); }
.k3-wide-chip-pink { background: linear-gradient(180deg, #f7b2bb 0%, #f197a2 100%); width: 100%; }

.k3-chip.active-choice,
.k3-wide-chip.active-choice,
.k3-total-card.active-choice,
.k3-type-card.active-choice {
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px rgba(255, 102, 102, 0.38);
}

.k3-type-row {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.k3-type-card {
  height: 54px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 5px 12px rgba(18, 28, 55, 0.12);
}

.k3-type-card span {
  font-size: 11px;
  font-weight: 600;
}

.k3-type-card.small { background: #6e9ff0; }
.k3-type-card.big { background: #f0aa55; }
.k3-type-card.even { background: #19bf6f; }
.k3-type-card.odd { background: #f25555; }

.k3-bet-panel .wingo-lock-overlay {
  border-radius: 14px;
}

.k3-history-wrap {
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
}

.k3-history-head,
.k3-history-row,
.k3-chart-row {
  display: grid;
  align-items: center;
}

.k3-history-head {
  height: 48px;
  background: #ff5f5f;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.k3-history-head.history-mode {
  grid-template-columns: 42% 12% 20% 26%;
}

.k3-history-head.chart-mode {
  grid-template-columns: 40% 34% 26%;
}

.k3-history-row {
  min-height: 44px;
  background: #fff;
  border-top: 1px solid #f1f1f1;
  font-size: 12px;
}

.k3-history-row.history-mode {
  grid-template-columns: 42% 12% 20% 26%;
}

.k3-chart-row {
  min-height: 44px;
  background: #fff;
  border-top: 1px solid #f1f1f1;
  font-size: 12px;
  grid-template-columns: 40% 34% 26%;
}

.k3-history-head > div,
.k3-history-row > div,
.k3-chart-row > div {
  text-align: center;
}

.k3-history-head > div:first-child,
.k3-history-row > div:first-child,
.k3-chart-row > div:first-child {
  text-align: left;
  padding-left: 12px;
}

.k3-history-row .sum-number {
  color: #13203d;
  font-weight: 700;
}

.k3-history-row .sum-meta {
  display: flex;
  justify-content: center;
  gap: 8px;
  color: #13203d;
}

.k3-history-row .results-pack,
.k3-chart-row .results-pack {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.k3-chart-row .pattern-text {
  color: #24324a;
  font-size: 12px;
}

.k3-empty-wrap {
  padding: 8px;
}

.k3-history-wrap .my-row-block {
  border-bottom: 1px solid #f1f2f4;
}

.k3-history-wrap .my-row-block:last-child {
  border-bottom: 0;
}

.k3-history-wrap .my-row-block.expanded {
  padding-bottom: 8px;
}

.k3-history-wrap .my-row-block .my-row {
  border-bottom: 0;
}

.k3-history-wrap .my-row-block .my-detail-card {
  margin-left: 0;
  margin-right: 0;
}

.k3-history-wrap .my-detail-line .detail-code {
  justify-self: start;
  text-align: left;
  color: #7a8eb4;
  word-break: break-all;
  max-width: 190px;
  padding-left: 8px;
}

.k3-history-wrap .tag.sum-badge {
  min-width: 52px;
  height: 40px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
}

.k3-history-wrap .tag.sum-badge.red { background: #ff5f5f; }
.k3-history-wrap .tag.sum-badge.green { background: #1fc168; }
.k3-history-wrap .tag.sum-badge.blue { background: #6e9ff0; }
.k3-history-wrap .tag.sum-badge.orange { background: #f0aa55; }
.k3-history-wrap .tag.sum-badge.purple {
  background: linear-gradient(135deg, #ff6b6b 0%, #be74ff 100%);
  font-size: 14px;
}

.k3-outcome-dice {
  width: auto;
  min-width: 118px;
  height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 0 auto 6px;
}

.k3-outcome-dice .k3-dice-image {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.k3-bet-sheet {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  pointer-events: none;
}

.k3-bet-sheet.hidden {
  display: none;
}

.k3-bet-sheet-panel {
  position: relative;
  width: var(--mobile-frame, min(100vw, 430px));
  max-width: 100vw;
  background: #fff;
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  overflow: hidden;
  box-shadow: 0 -10px 30px rgba(0,0,0,0.22);
  pointer-events: auto;
}

.k3-bet-sheet-top {
  height: 104px;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 11px;
  clip-path: polygon(0 0, 100% 0, 100% 72%, 50% 100%, 0 72%);
}

.k3-bet-sheet-top.theme-red { background: linear-gradient(90deg, #ff6666 0%, #ff7b7b 100%); }
.k3-bet-sheet-top.theme-green { background: linear-gradient(90deg, #24c267 0%, #54d48d 100%); }
.k3-bet-sheet-top.theme-purple { background: linear-gradient(90deg, #ff6666 0%, #b96cff 100%); }
.k3-bet-sheet-top.theme-orange { background: linear-gradient(90deg, #ffb24f 0%, #ffcb73 100%); }
.k3-bet-sheet-top.theme-blue { background: linear-gradient(90deg, #6f9ef0 0%, #8bb7ff 100%); }
.k3-bet-sheet-top.theme-pink { background: linear-gradient(90deg, #ff6666 0%, #d374ff 100%); }
.k3-bet-sheet-top.theme-salmon { background: linear-gradient(90deg, #ff7c7c 0%, #ff8e8e 100%); }

.k3-bet-sheet-body {
  padding: 16px 14px 0;
}

.k3-bet-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.k3-bet-pick {
  min-width: 36px;
  height: 26px;
  padding: 0 10px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.k3-bet-pick.theme-red { background: #ff6666; }
.k3-bet-pick.theme-green { background: #20bf67; }
.k3-bet-pick.theme-purple { background: #ba6df1; }
.k3-bet-pick.theme-orange { background: #ffb04d; }
.k3-bet-pick.theme-blue { background: #6f9ef0; }
.k3-bet-pick.theme-pink { background: #f39da5; }
.k3-bet-pick.theme-salmon { background: #ff7c7c; }

.k3-bet-sheet .wingo-bet-chip-row button.active[data-theme="green"],
.k3-bet-sheet .wingo-bet-stepper[data-theme="green"],
.k3-bet-sheet .wingo-bet-confirm[data-theme="green"] { background: #1cbc57; border-color: transparent; color: #fff; }

.k3-bet-sheet .wingo-bet-chip-row button.active[data-theme="red"],
.k3-bet-sheet .wingo-bet-stepper[data-theme="red"],
.k3-bet-sheet .wingo-bet-confirm[data-theme="red"] { background: #ff5a5a; border-color: transparent; color: #fff; }

.k3-bet-sheet .wingo-bet-chip-row button.active[data-theme="purple"],
.k3-bet-sheet .wingo-bet-stepper[data-theme="purple"],
.k3-bet-sheet .wingo-bet-confirm[data-theme="purple"] { background: #b15ef5; border-color: transparent; color: #fff; }

.k3-bet-sheet .wingo-bet-chip-row button.active[data-theme="orange"],
.k3-bet-sheet .wingo-bet-stepper[data-theme="orange"],
.k3-bet-sheet .wingo-bet-confirm[data-theme="orange"] { background: #f8ad4b; border-color: transparent; color: #fff; }

.k3-bet-sheet .wingo-bet-chip-row button.active[data-theme="blue"],
.k3-bet-sheet .wingo-bet-stepper[data-theme="blue"],
.k3-bet-sheet .wingo-bet-confirm[data-theme="blue"] { background: #679ae0; border-color: transparent; color: #fff; }

.k3-bet-sheet .wingo-bet-chip-row button.active[data-theme="pink"],
.k3-bet-sheet .wingo-bet-stepper[data-theme="pink"],
.k3-bet-sheet .wingo-bet-confirm[data-theme="pink"] { background: linear-gradient(103deg, #ff5a5a 0 50%, #bf66ff 50% 100%); border-color: transparent; color: #fff; }

.k3-bet-sheet .wingo-bet-chip-row button.active[data-theme="salmon"],
.k3-bet-sheet .wingo-bet-stepper[data-theme="salmon"],
.k3-bet-sheet .wingo-bet-confirm[data-theme="salmon"] { background: #ff7c7c; border-color: transparent; color: #fff; }

.k3-control-row {
  align-items: center;
}

.k3-control-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.k3-control-meta {
  color: #8792a8;
  font-size: 11px;
}

.k3-control-inputs {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.k3-control-inputs input {
  width: 74px;
  height: 30px;
  border: 1px solid #e4e7f0;
  border-radius: 8px;
  text-align: center;
}

.k3-help-card {
  width: min(100%, 304px);
  padding: 22px 18px 18px;
  border-radius: 18px;
  position: relative;
}

.k3-help-dice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
}

.k3-help-dice .k3-dice-image {
  width: 48px;
  height: 48px;
}

.k3-help-text {
  color: #7b8498;
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
}

.k3-help-close {
  position: static;
  width: 34px;
  height: 34px;
  margin: 14px auto 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.38);
  color: #fff;
  border-radius: 50%;
}

@media (max-width: 390px) {
  .k3-total-grid {
    gap: 10px 4px;
  }

  .k3-chip-grid.six {
    gap: 8px 4px;
  }

  .k3-chip,
  .k3-wide-chip {
    font-size: 11px;
    height: 36px;
  }

  .k3-sum-ball-shell {
    width: 48px;
    height: 48px;
  }

  .k3-sum-ball-shell img {
    width: 48px;
    height: 48px;
  }
}

/* Stability pass: compact K3 on tall and narrow mobile browsers without shifting controls. */
.k3-content {
  padding-top: calc(52px + env(safe-area-inset-top, 0px)) !important;
}

.k3-bg {
  height: clamp(292px, 78vw, 344px) !important;
}

.k3-ticket-card {
  border-radius: 16px !important;
  padding: clamp(10px, 3vw, 12px) clamp(10px, 3vw, 12px) clamp(12px, 3.8vw, 16px) !important;
}

.k3-ticket-meta strong {
  font-size: clamp(14px, 4.2vw, 18px) !important;
  font-weight: 600 !important;
}

.k3-ticket-digits span {
  width: clamp(15px, 4.8vw, 18px) !important;
  height: clamp(22px, 7vw, 26px) !important;
  font-size: clamp(15px, 5.2vw, 20px) !important;
}

.k3-dice-stage {
  min-height: clamp(82px, 25vw, 112px) !important;
}

.k3-dice-slot,
.k3-dice-cell {
  height: 98px !important;
  min-height: 98px !important;
}

.k3-dice-stage .k3-dice-cell .k3-dice-svg {
  width: clamp(58px, 18vw, 76px) !important;
  height: clamp(58px, 18vw, 76px) !important;
}

/* K3 compact restore: keep the shared wallet/header UI identical to the other lottery pages. */
#page-k3,
#page-k3.active {
  overflow-x: hidden !important;
}

.k3-root {
  width: var(--mobile-frame, min(100vw, 430px)) !important;
  max-width: 100% !important;
  overflow-x: hidden !important;
}

.k3-content {
  padding-left: clamp(8px, 2.6vw, 10px) !important;
  padding-right: clamp(8px, 2.6vw, 10px) !important;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)) !important;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

.k3-content::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

.k3-root .wallet-card {
  min-height: clamp(112px, 31vw, 136px) !important;
  max-height: 150px !important;
  padding: clamp(13px, 3.4vw, 18px) clamp(14px, 4.8vw, 21px) clamp(13px, 3.4vw, 16px) !important;
  background-size: 100% 100% !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  border-radius: 21px !important;
  box-shadow: none !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

.k3-root .wallet-amount {
  position: relative !important;
  display: grid !important;
  grid-template-columns: 1fr auto 1fr !important;
  align-items: center !important;
  color: #0e2348 !important;
  font-size: clamp(17px, 5vw, 21px) !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  text-align: center !important;
}

.k3-root .wallet-amount > span {
  grid-column: 2 !important;
  justify-self: center !important;
}

.k3-root .wallet-amount .wingo-inline-refresh {
  grid-column: 3 !important;
  justify-self: start !important;
  margin-left: 12px !important;
}

.k3-root .wallet-label {
  margin-top: 7px !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  gap: 4px !important;
  color: #0e2348 !important;
  font-size: 13.5px !important;
}

.k3-root .wallet-label img {
  width: 14px !important;
  height: 14px !important;
}

.k3-root .wallet-actions {
  margin-top: clamp(12px, 4vw, 18px) !important;
  display: flex !important;
  justify-content: space-between !important;
  gap: 12px !important;
}

.k3-root .wallet-actions button {
  flex: 1 1 0 !important;
  width: auto !important;
  height: clamp(32px, 9.2vw, 38px) !important;
  border: 0 !important;
  border-radius: 21px !important;
  color: #fff !important;
  font-size: clamp(13px, 3.9vw, 15px) !important;
  font-weight: 600 !important;
}

.k3-panel {
  margin-top: clamp(10px, 3.4vw, 16px) !important;
}

.k3-ticket-head {
  grid-template-columns: minmax(0, 1fr) auto minmax(88px, auto) !important;
  gap: clamp(4px, 1.4vw, 6px) !important;
}

.k3-ticket-meta {
  min-width: 0 !important;
}

.k3-ticket-meta strong {
  max-width: 100% !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.k3-ticket-time {
  min-width: 88px !important;
  overflow: hidden !important;
}

.k3-ticket-digits {
  gap: 2px !important;
}

.k3-ticket-digits span {
  width: clamp(14px, 4.2vw, 18px) !important;
  height: clamp(22px, 6.6vw, 26px) !important;
  font-size: clamp(15px, 4.8vw, 20px) !important;
}

.k3-ticket-digits .k3-ticket-colon {
  width: 6px !important;
}

@media (max-width: 360px) {
  .k3-ticket-head {
    grid-template-columns: minmax(0, 1fr) minmax(82px, auto) !important;
  }

  .k3-ticket-head .k3-how-button {
    grid-column: 1 / 2 !important;
    grid-row: 2 !important;
    justify-self: start !important;
    margin-top: 6px !important;
  }

  .k3-ticket-time {
    grid-column: 2 !important;
    grid-row: 1 / 3 !important;
    align-self: start !important;
  }
}

/* K3 chart/history restore: compact result rows must not inherit stage dice sizing. */
.k3-history-wrap .k3-dice-image.mini,
.k3-outcome-dice .k3-dice-image.mini,
.k3-my-row-card .k3-dice-image.mini,
.k3-help-dice .k3-dice-image.mini,
.bet-result-k3 .k3-dice-image.mini {
  width: 24px !important;
  height: 24px !important;
  max-width: 24px !important;
  max-height: 24px !important;
  flex: 0 0 24px !important;
  object-fit: contain !important;
}

.k3-history-row.history-mode,
.k3-history-head.history-mode {
  grid-template-columns: minmax(0, 36%) minmax(36px, 12%) minmax(64px, 20%) minmax(72px, 32%) !important;
}

.k3-chart-row,
.k3-history-head.chart-mode {
  grid-template-columns: minmax(0, 42%) minmax(76px, 30%) minmax(0, 28%) !important;
}

.k3-history-row > div,
.k3-chart-row > div,
.k3-history-head > div {
  min-width: 0 !important;
}

.k3-history-row.history-mode > div:first-child,
.k3-chart-row > div:first-child {
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.k3-history-row .results-pack,
.k3-chart-row .results-pack {
  min-width: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 3px !important;
  overflow: hidden !important;
}

.k3-chart-row .pattern-text {
  font-size: 11px !important;
  line-height: 1.15 !important;
  white-space: normal !important;
  word-break: normal !important;
  overflow-wrap: anywhere !important;
  text-align: left !important;
  padding-right: 4px !important;
}

/* Lottery 2.0 compatibility guard: history/chart dice stay compact, main K3 dice stage stays old style. */
.k3-history-wrap,
.k3-history-body,
.k3-history-row,
.k3-chart-row {
  max-width: 100% !important;
  overflow: hidden !important;
}

.k3-history-wrap .results-pack,
.k3-chart-row .results-pack,
.k3-history-row .results-pack {
  max-width: 96px !important;
}

.k3-history-wrap .results-pack .k3-dice-image,
.k3-chart-row .results-pack .k3-dice-image,
.k3-history-row .results-pack .k3-dice-image,
.k3-history-wrap .results-pack .k3-dice-mini-wrap,
.k3-chart-row .results-pack .k3-dice-mini-wrap,
.k3-history-row .results-pack .k3-dice-mini-wrap {
  width: 24px !important;
  height: 24px !important;
  max-width: 24px !important;
  max-height: 24px !important;
  flex: 0 0 24px !important;
  object-fit: contain !important;
}

.k3-history-wrap .results-pack .k3-dice-mini-wrap .k3-dice-svg,
.k3-chart-row .results-pack .k3-dice-mini-wrap .k3-dice-svg,
.k3-history-row .results-pack .k3-dice-mini-wrap .k3-dice-svg {
  width: 24px !important;
  height: 24px !important;
}

.k3-ticket-head {
  max-width: 100% !important;
}

.k3-ticket-meta,
.k3-ticket-time {
  min-width: 0 !important;
}

/* K3 final mobile repair: keep old layout, remove broken 2.0 overflow overrides. */
.k3-root .top-header .back-button::before,
.k3-root .top-header .back-button::after {
  content: none !important;
  display: none !important;
}

.k3-root .top-header .back-button {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  flex: 0 0 34px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: transparent !important;
}

.k3-root .top-header .back-button img {
  display: block !important;
  width: 28px !important;
  height: 28px !important;
  object-fit: contain !important;
}

.k3-root .timer-card {
  min-height: clamp(84px, 22vw, 96px) !important;
  border-radius: 14px !important;
  color: #768096 !important;
  background: transparent !important;
}

.k3-root .timer-card img {
  filter: grayscale(1) opacity(0.5) !important;
}

.k3-root .timer-card.active {
  background: linear-gradient(180deg, #ff8080 0%, rgba(255, 128, 128, 0) 100%) !important;
  box-shadow: none !important;
}

.k3-root .timer-card.active img {
  filter: drop-shadow(0 2px 4px rgba(255, 111, 111, 0.28)) !important;
  opacity: 1 !important;
}

.k3-root .timer-card.active span strong,
.k3-root .timer-card.active span em,
.k3-root .timer-card.active span {
  color: #f95959 !important;
}

.k3-root .timer-card span {
  max-width: 100% !important;
  line-height: 1.08 !important;
  text-align: center !important;
  white-space: normal !important;
}

.k3-root .k3-ticket-card {
  margin-top: 12px !important;
}

.k3-root .k3-ticket-head {
  grid-template-columns: minmax(0, 1fr) auto !important;
  gap: clamp(6px, 2vw, 8px) !important;
}

.k3-root .k3-ticket-meta strong {
  display: block !important;
  max-width: 100% !important;
  font-size: clamp(14px, 4.2vw, 18px) !important;
  font-weight: 600 !important;
  letter-spacing: -0.55px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.k3-root .k3-how-button {
  height: 24px !important;
  min-width: 84px !important;
  font-size: 9px !important;
  font-weight: 500 !important;
}

.k3-root .k3-dice-stage {
  min-height: 98px !important;
  padding: 10px 9px !important;
  gap: 8px !important;
}

.k3-root .k3-dice-slot,
.k3-root .k3-dice-cell {
  height: 98px !important;
  min-height: 98px !important;
  border-radius: 6px !important;
}

.k3-root .k3-dice-stage .k3-dice-cell .k3-dice-svg {
  width: clamp(58px, 18vw, 76px) !important;
  height: clamp(58px, 18vw, 76px) !important;
}

.k3-root .k3-history-head.history-mode,
.k3-root .k3-history-row.history-mode {
  grid-template-columns: minmax(128px, 1.3fr) minmax(30px, 0.35fr) minmax(70px, 0.75fr) minmax(80px, 0.85fr) !important;
}

.k3-root .k3-history-head.chart-mode,
.k3-root .k3-chart-row {
  grid-template-columns: minmax(128px, 1.25fr) minmax(82px, 0.85fr) minmax(88px, 0.9fr) !important;
}

.k3-root .k3-history-row.history-mode > div:first-child,
.k3-root .k3-chart-row > div:first-child {
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: nowrap !important;
  font-size: clamp(10px, 2.75vw, 11.5px) !important;
  letter-spacing: -0.45px !important;
  padding-left: 8px !important;
}

.k3-root .k3-history-head > div:first-child {
  padding-left: 8px !important;
}

.k3-root .k3-history-row .sum-meta {
  gap: 4px !important;
  font-size: 11px !important;
}

.k3-root .k3-history-row .results-pack,
.k3-root .k3-chart-row .results-pack {
  max-width: 88px !important;
  gap: 3px !important;
  justify-content: flex-end !important;
}

.k3-root .k3-history-row .results-pack .k3-dice-image,
.k3-root .k3-chart-row .results-pack .k3-dice-image {
  width: 22px !important;
  height: 22px !important;
  max-width: 22px !important;
  max-height: 22px !important;
  flex: 0 0 22px !important;
}

.k3-root .k3-chart-row .pattern-text {
  font-size: 10.5px !important;
  line-height: 1.12 !important;
  overflow-wrap: normal !important;
  word-break: keep-all !important;
}

@media (max-width: 360px) {
  .k3-root .k3-ticket-head {
    grid-template-columns: minmax(105px, 1fr) minmax(82px, auto) !important;
  }

  .k3-root .k3-history-head.history-mode,
  .k3-root .k3-history-row.history-mode {
    grid-template-columns: minmax(118px, 1.25fr) minmax(28px, 0.35fr) minmax(62px, 0.7fr) minmax(72px, 0.85fr) !important;
  }

  .k3-root .k3-history-head.chart-mode,
  .k3-root .k3-chart-row {
    grid-template-columns: minmax(118px, 1.2fr) minmax(74px, 0.8fr) minmax(78px, 0.8fr) !important;
  }
}
